Exemple #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return OASEO_BOL_SlugDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #2
0
 /**
  * @param string $entityType
  * @param integer $entityId
  * @param callback $callback
  * @param string $dtoProperty
  */
 public function checkEntityUpdate($entityType, $entityId, $callback, $dtoProperty)
 {
     $dto = call_user_func($callback, $entityId);
     $vars = get_object_vars($dto);
     if (empty($vars[$dtoProperty])) {
         return;
     }
     $procSlug = $this->makeSlug($vars[$dtoProperty]);
     $slugArr = explode('-', $this->slugs['id'][$entityType][$entityId]->getString());
     $potencialId = $slugArr[sizeof($slugArr) - 1];
     if (is_numeric($potencialId) && (int) $potencialId === (int) $entityId) {
         $procSlug .= '-' . $entityId;
     }
     if ($procSlug !== $this->slugs['id'][$entityType][$entityId]->getString()) {
         $this->slugDao->updateSlugStatus($entityType, $entityId);
         $slugDto = $this->slugDao->findSlug($entityType, $entityId, $procSlug);
         if ($slugDto === null) {
             $slugDto = new OASEO_BOL_Slug();
             $slugDto->setEntityType($entityType);
             $slugDto->setEntityId($entityId);
             $slugDto->setString($procSlug);
         }
         $slugDto->setActive(true);
         $this->slugDao->save($slugDto);
     }
 }