Ejemplo n.º 1
0
 /**
  * Installation of the property
  */
 protected function install($object)
 {
     $model = Property::find()->where(['var_name' => $object->varName()])->one();
     if ($model) {
         $model->setAttributes(['module_name' => $object->moduleName, 'class_name' => $object::className()]);
         $model->update(false);
         return $model->id;
     } else {
         $model = new Property();
         $model->setAttributes(['var_name' => $object->varName(), 'module_name' => $object->moduleName, 'class_name' => $object::className()]);
         $insert = $model->insert(false);
         if ($insert) {
             return $model->id;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * {@inheritDoc}
  * @see \yii\base\BootstrapInterface::bootstrap()
  */
 public function bootstrap($app)
 {
     $findProperty = Property::findOne(['class_name' => GroupAuthProperty::className()]);
     if ($findProperty) {
         Yii::$app->menu->on(Menu::MENU_ITEM_EVENT, [$this, 'hideElements'], CmsProperty::findAll(['admin_prop_id' => $findProperty->id]));
     }
 }
Ejemplo n.º 3
0
 /**
  * Get all available administration regisetered properties.
  *
  * @return array Get all properties.
  */
 public function actionDataProperties()
 {
     $data = [];
     foreach (Property::find()->all() as $item) {
         $object = Property::getObject($item->class_name);
         $data[] = ['id' => $item->id, 'var_name' => $object->varName(), 'option_json' => $object->options(), 'label' => $object->label(), 'type' => $object->type(), 'default_value' => $object->defaultValue(), 'i18n' => $object->i18n];
     }
     return $data;
 }
Ejemplo n.º 4
0
 public function actionGetProperties($navId)
 {
     $data = [];
     foreach (Property::find()->select(['admin_prop_id', 'value'])->where(['nav_id' => $navId])->asArray()->all() as $row) {
         $object = \luya\admin\models\Property::findOne($row['admin_prop_id']);
         $blockObject = $object->createObject($row['value']);
         $value = $blockObject->getAdminValue();
         $row['value'] = is_numeric($value) ? (int) $value : $value;
         $data[] = $row;
     }
     return $data;
 }
Ejemplo n.º 5
0
 public function getAdminProperty()
 {
     return $this->hasOne(AdminProperty::className(), ['id' => 'admin_prop_id']);
 }