Example #1
0
 /**
  * @return mixed
  */
 public function getDescription()
 {
     if (is_null($this->description)) {
         $text = $this->getText();
         $this->description = StringUtils::cutStr($text, 160);
     }
     return $this->description;
 }
 public function rmAction()
 {
     $this->autoRenderOff();
     $manager = $this->getRelationsManager();
     $id = StringUtils::idFromStr($this->getRequest()->getUriPartByNum(6));
     if ($id) {
         $manager->deleteById($id);
     }
     $this->getResponse()->redirect("/admin/deltadb/relations/list/" . $this->getRelationName());
 }
Example #3
0
 /**
  * @return mixed
  */
 public function getMetaDescription()
 {
     if (empty($this->metaDescription)) {
         $desc = $this->getDescription();
         if (!empty($desc)) {
             $this->metaDescription = StringUtils::cutStr($desc, 160);
         } else {
             $this->metaDescription = "Подробная информация  о {$this->getMetaTitle()}";
         }
     }
     return $this->metaDescription;
 }
Example #4
0
 function __isset($field)
 {
     $field = StringUtils::lowDashToCamelCase($field);
     $fieldList = array_flip($this->getFieldsList());
     return isset($fieldList[$field]);
 }
Example #5
0
 public function findOthers($currentId, $currentName)
 {
     $currentName = StringUtils::camelCaseToLowDash($currentName);
     $currentPart = $this->filterPartName($currentName);
     $otherPart = $this->getOtherPartName($currentPart);
     $othersIds = $this->findOtherPartIds([$currentId], $currentPart);
     $otherManager = $this->getPartManager($otherPart);
     $items = $otherManager->findByIds($othersIds);
     return $items;
 }
Example #6
0
 public function getWhereParams(array $criteria)
 {
     $whereParams = [];
     foreach ($criteria as $field => $value) {
         if (is_object($value)) {
             $class = StringUtils::cutClassName(get_class($value));
             switch ($class) {
                 case "Between":
                     /** @var Between $value */
                     $whereParams[] = $value->getStart();
                     $whereParams[] = $value->getEnd();
                     break;
                 case "ILike":
                     /** @var ILike $value */
                     $whereParams[] = $value->getQuery();
                     break;
                 case "PgPoint":
                     break;
                 default:
                     throw new \InvalidArgumentException("where class {$class} not implement");
             }
         } elseif (is_array($value)) {
             foreach ($value as $valueItem) {
                 $whereParams[] = $valueItem;
             }
         } elseif (is_null($value)) {
             continue;
         } else {
             $whereParams[] = $value;
         }
     }
     return $whereParams;
 }
Example #7
0
 public function __toString()
 {
     $arrayData = $this->toArray();
     return StringUtils::toString($arrayData, true);
 }
Example #8
0
 public function loadUntrusted(EntityInterface &$entity, array $data, $id = null)
 {
     $data = ArrayUtils::renameKeys($data, function ($var) {
         return StringUtils::camelCaseToLowDash($var);
     });
     $id = $id ?: isset($data["id"]) ? $data["id"] : null;
     if ($id) {
         if ($this->getIdMap()->has($id)) {
             $entityHas = $this->getIdMap()->get($id);
             if ($entityHas->isTrusted()) {
                 $entity = $entityHas;
                 return $entity;
             }
         }
     }
     $entity->setUntrusted();
     $this->load($entity, $data);
     $this->getIdMap()->set($id, $entity);
     return $entity;
 }
Example #9
0
 public function loadAssets($files)
 {
     $files = (array) $files;
     $am = $this->getAssetManager();
     $assets = [];
     foreach ($files as $name => $file) {
         if (StringUtils::isText($name)) {
             if ($am->has($name)) {
                 $asset = new AssetReference($am, $name);
             } else {
                 $asset = $this->loadAsset($file);
                 $am->set($name, $asset);
             }
         } else {
             $asset = $this->loadAsset($file);
         }
         $assets[] = $asset;
     }
     if (empty($assets)) {
         throw new AssetException("Empty assets");
     }
     $ac = new AssetCollection($assets);
     return $ac;
 }