Pimcore\Model\Property\Predefined::create PHP Метод

create() публичный статический Метод

public static create ( ) : self
Результат self
    public static function create()
    {
        $type = new self();
        $type->save();
        return $type;
    }

Usage Example

Пример #1
0
 public function propertiesAction()
 {
     if ($this->getParam("data")) {
         $this->checkPermission("predefined_properties");
         if ($this->getParam("xaction") == "destroy") {
             $data = \Zend_Json::decode($this->getParam("data"));
             if (\Pimcore\Tool\Admin::isExtJS6()) {
                 $id = $data["id"];
             } else {
                 $id = $data;
             }
             $property = Property\Predefined::getById($id);
             $property->delete();
             $this->_helper->json(["success" => true, "data" => []]);
         } elseif ($this->getParam("xaction") == "update") {
             $data = \Zend_Json::decode($this->getParam("data"));
             // save type
             $property = Property\Predefined::getById($data["id"]);
             $property->setValues($data);
             $property->save();
             $this->_helper->json(["data" => $property, "success" => true]);
         } elseif ($this->getParam("xaction") == "create") {
             $data = \Zend_Json::decode($this->getParam("data"));
             unset($data["id"]);
             // save type
             $property = Property\Predefined::create();
             $property->setValues($data);
             $property->save();
             $this->_helper->json(["data" => $property, "success" => true]);
         }
     } else {
         // get list of types
         $list = new Property\Predefined\Listing();
         if ($this->getParam("filter")) {
             $filter = $this->getParam("filter");
             $list->setFilter(function ($row) use($filter) {
                 foreach ($row as $value) {
                     if (strpos($value, $filter) !== false) {
                         return true;
                     }
                 }
                 return false;
             });
         }
         $list->load();
         $properties = [];
         if (is_array($list->getProperties())) {
             foreach ($list->getProperties() as $property) {
                 $properties[] = $property;
             }
         }
         $this->_helper->json(["data" => $properties, "success" => true, "total" => $list->getTotalCount()]);
     }
 }
All Usage Examples Of Pimcore\Model\Property\Predefined::create