public function test_with_our_resolver()
 {
     $resolver = self::$resolver;
     $record = ActiveRecord::from(['uid' => 0], ['dummy']);
     $this->assertNotEmpty($resolver(self::$admin_user, $record));
     $this->assertEmpty($resolver(self::$simple_user, $record));
     $this->assertEmpty($resolver(self::$guest_user, $record));
     $record = ActiveRecord::from(['uid' => 1], ['dummy']);
     $this->assertNotEmpty($resolver(self::$admin_user, $record));
     $this->assertEmpty($resolver(self::$simple_user, $record));
     $this->assertEmpty($resolver(self::$guest_user, $record));
     $record = ActiveRecord::from(['uid' => 2], ['dummy']);
     $this->assertNotEmpty($resolver(self::$admin_user, $record));
     $this->assertNotEmpty($resolver(self::$simple_user, $record));
     $this->assertEmpty($resolver(self::$guest_user, $record));
     $record = ActiveRecord::from(['uid' => 123], ['dummy']);
     $this->assertNotEmpty($resolver(self::$admin_user, $record));
     $this->assertEmpty($resolver(self::$simple_user, $record));
     $this->assertEmpty($resolver(self::$guest_user, $record));
 }
示例#2
0
 /**
  * Return the _primary_ absolute URL for the node.
  *
  * @param ActiveRecord $record
  *
  * @return string The primary absolute URL for the node.
  */
 public static function get_absolute_url(ActiveRecord $record)
 {
     return $record->absolute_url('view');
 }
示例#3
0
 /**
  * The `$model` property defaults to "taxonomy.terms".
  *
  * @param string $model
  */
 public function __construct($model = 'taxonomy.terms')
 {
     parent::__construct($model);
 }
示例#4
0
 /**
  * @param string $model Defaults to `users.noncelogin`.
  */
 public function __construct($model = 'users.noncelogin')
 {
     parent::__construct($model);
 }
示例#5
0
 /**
  * Sets {@link $created_at} to "now" if it is empty, and sets {@link $updated_at} to "now"
  * before passing the method to the parent class.
  *
  * Adds `language` if it is not defined.
  */
 protected function alter_persistent_properties(array $properties, \ICanBoogie\ActiveRecord\Model $model)
 {
     if ($this->get_created_at()->is_empty) {
         $this->set_created_at('now');
     }
     $this->set_updated_at('now');
     return parent::alter_persistent_properties($properties, $model) + ['language' => ''];
 }
示例#6
0
 public static function get_url(ActiveRecord $record)
 {
     return $record->url();
 }
示例#7
0
 /**
  * Clears the sites cache.
  */
 public function save()
 {
     global $core;
     unset($core->vars['cached_sites']);
     return parent::save();
 }
示例#8
0
 /**
  * Defaults model to "journal".
  */
 public function __construct($model = 'journal')
 {
     parent::__construct($model);
 }
示例#9
0
 public function __construct($model = 'images.albums/photos')
 {
     parent::__construct($model);
 }
示例#10
0
 public function __construct($model = 'pages/contents')
 {
     parent::__construct($model);
 }
示例#11
0
 protected function alter_persistent_properties(array $properties, \ICanBoogie\ActiveRecord\Model $model)
 {
     $properties = parent::alter_persistent_properties($properties, $model);
     if (!$this->result_id && $properties['created_at']->is_empty) {
         $properties['created_at'] = DateTime::now();
     }
     if ($properties['updated_at']->is_empty) {
         $properties['updated_at'] = DateTime::now();
     }
     return $properties;
 }
示例#12
0
 /**
  * If the `options` or `validation_options` magic properties are defined they are mapped
  * to their serialized conterparts and unset. This allows the developper to defined
  * options and validation options using unserialized data.
  *
  * @param string $model Default: "forms.blueprints/items".
  */
 public function __construct($model = 'forms.blueprints/items')
 {
     if (isset($this->options)) {
         $this->volatile_set_options($this->options);
     }
     unset($this->options);
     if (isset($this->validation_options)) {
         $this->volatile_set_validation_options($this->validation_options);
     }
     unset($this->validation_options);
     parent::__construct($model);
 }
示例#13
0
 /**
  * Defaults model to "comments".
  */
 public function __construct($model = 'comments')
 {
     parent::__construct($model);
 }
示例#14
0
 /**
  * Adds the {@link $logged_at} property.
  */
 public function to_array()
 {
     $array = parent::to_array();
     if ($this->password) {
         $array['password'] = $this->password;
     }
     return $array;
 }