コード例 #1
0
ファイル: Model.php プロジェクト: DavBfr/BlogMVC
 public function save(array $properties, $key = null, array $options = [])
 {
     if (empty($properties['slug'])) {
         $properties['slug'] = \ICanBoogie\normalize($properties['name']);
     }
     return parent::save($properties, $key, $options);
 }
コード例 #2
0
 public function save(array $properties, $key = null, array $options = array())
 {
     if (!$key && empty($properties['uuid'])) {
         $properties['uuid'] = $this->generate_uuid();
     }
     return parent::save($properties, $key, $options);
 }
コード例 #3
0
ファイル: model.constructor.php プロジェクト: icybee/core
 /**
  * Overwrites the `constructor` property of new records.
  */
 public function save(array $properties, $key = null, array $options = array())
 {
     if (!$key && empty($properties[self::T_CONSTRUCTOR])) {
         $properties[self::T_CONSTRUCTOR] = $this->constructor;
     }
     return parent::save($properties, $key, $options);
 }
コード例 #4
0
 /**
  * Adds the `status` and `notify` properties if they are not defined, they default to
  * `pending` and `no`.
  *
  * @throws \InvalidArgumentException if the value of the `notify` property is not one of `no`,
  * `yes`, `author` or `done`.
  */
 public function save(array $properties, $key = null, array $options = array())
 {
     $properties += array(Comment::CREATED => DateTime::now(), Comment::STATUS => 'pending', Comment::NOTIFY => 'no');
     if (!in_array($properties[Comment::NOTIFY], array('no', 'yes', 'author', 'done'))) {
         throw new \InvalidArgumentException(\ICanBoogie\format('Invalid value for property %property: %value', array('%property' => Comment::NOTIFY, '%value' => $properties[Comment::NOTIFY])));
     }
     return parent::save($properties, $key, $options);
 }
コード例 #5
0
 /**
  * If the `termslug` property is empty it is created from the `term` property, otherwise
  * the it is normalized.
  */
 public function save(array $properties, $key = null, array $options = array())
 {
     if (isset($properties[Term::TERM]) && empty($properties[Term::TERMSLUG])) {
         $properties[Term::TERMSLUG] = \Icybee\slugize($properties[Term::TERM]);
     } else {
         if (isset($properties[Term::TERMSLUG])) {
             $properties[Term::TERMSLUG] = \ICanBoogie\normalize($properties[Term::TERMSLUG]);
         }
     }
     return parent::save($properties, $key, $options);
 }