コード例 #1
0
ファイル: Embed.php プロジェクト: as3io/modlr
 /**
  * Constructor.
  *
  * @param   EmbedMetadata   $metadata   The internal embed metadata that supports this Embed.
  * @param   Store           $store      The model store service for handling persistence operations.
  * @param   array|null      $properties The embed's properties from the db layer to init the embed with. New embeds will constructed with a null record.
  */
 public function __construct(EmbedMetadata $metadata, Store $store, array $properties = null)
 {
     parent::__construct($metadata, $store, $properties);
     $this->getState()->setLoaded();
 }
コード例 #2
0
ファイル: AbstractCollection.php プロジェクト: as3io/modlr
 /**
  * Sets a model to a collection property (original, added, removed, models).
  *
  * @param   string          $property   The property key
  * @param   AbstractModel   $model      The model to set.
  * @return  self
  */
 protected function set($property, AbstractModel $model)
 {
     $key = $model->getCompositeKey();
     $this->{$property}[$key] = $model;
     if ('models' === $property) {
         $keys = array_flip($this->modelKeyMap);
         if (!isset($keys[$key])) {
             $this->modelKeyMap[] = $key;
             $this->totalCount++;
         }
     }
     return $this;
 }
コード例 #3
0
ファイル: Model.php プロジェクト: as3io/modlr
 /**
  * {@inheritdoc}
  *
  * Overloaded to support global model defaults.
  *
  */
 protected function applyDefaultAttrValues(array $attributes = [])
 {
     $attributes = parent::applyDefaultAttrValues($attributes);
     // Set defaults for the entire entity.
     foreach ($this->getMetadata()->defaultValues as $key => $value) {
         if (isset($attributes[$key])) {
             continue;
         }
         $attributes[$key] = $this->convertAttributeValue($key, $value);
     }
     return $attributes;
 }