Xpressengine\Document\Models\Document::checkRequired PHP Method

checkRequired() public method

Check required attributes
public checkRequired ( array $attributes ) : void
$attributes array attributes
return void
    public function checkRequired(array $attributes)
    {
        if ($attributes['userId'] === null) {
            throw new ValueRequiredException(['name' => 'userId']);
        }
        if ($attributes['writer'] === null) {
            throw new ValueRequiredException(['name' => 'writer']);
        }
        if ($attributes['instanceId'] === null) {
            throw new ValueRequiredException(['name' => 'instanceId']);
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * update document
  *
  * @param Document $doc document model
  * @return Document
  */
 public function put(Document $doc)
 {
     $doc->getConnection()->beginTransaction();
     $doc->pureContent = $doc->getPureContent($doc->content);
     $doc->checkRequired($doc->getAttributes());
     $doc->save();
     $this->removeDivision($doc);
     $this->addRevision($doc);
     $doc->getConnection()->commit();
     return $doc;
 }