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)); }
/** * 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'); }
/** * The `$model` property defaults to "taxonomy.terms". * * @param string $model */ public function __construct($model = 'taxonomy.terms') { parent::__construct($model); }
/** * @param string $model Defaults to `users.noncelogin`. */ public function __construct($model = 'users.noncelogin') { parent::__construct($model); }
/** * 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' => '']; }
public static function get_url(ActiveRecord $record) { return $record->url(); }
/** * Clears the sites cache. */ public function save() { global $core; unset($core->vars['cached_sites']); return parent::save(); }
/** * Defaults model to "journal". */ public function __construct($model = 'journal') { parent::__construct($model); }
public function __construct($model = 'images.albums/photos') { parent::__construct($model); }
public function __construct($model = 'pages/contents') { parent::__construct($model); }
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; }
/** * 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); }
/** * Defaults model to "comments". */ public function __construct($model = 'comments') { parent::__construct($model); }
/** * Adds the {@link $logged_at} property. */ public function to_array() { $array = parent::to_array(); if ($this->password) { $array['password'] = $this->password; } return $array; }