Example #1
0
 /**
  * Injects everything into the passed object/instance
  *
  * @param mixed $object instance
  * @param string $containerName the container that holds the maps/dependencies
  */
 public static function inject($object, $containerName = 'main')
 {
     $injector = new self();
     $injector->setObject($object);
     $injector->setContainer(Pd_Container::get($containerName));
     $injector->injectObject();
 }
 /**
  * Standard factory method to instantiate a populated object.
  *
  * @param BaseDataObject $object     The object being rendered
  * @param                $urlType    The type of URL connection
  * @param array          $attributes HTML tag attributes
  * @return mixed
  */
 public static function factory(RendererInterface $renderer, BaseDataObject $object, $urlType, array $attributes = array())
 {
     $htmlRenderer = new self();
     $htmlRenderer->setRenderer($renderer);
     $htmlRenderer->setObject($object);
     $htmlRenderer->setUrlType($urlType);
     $htmlRenderer->setAttributes($attributes);
     return $htmlRenderer->build();
 }
 public static function initialize($user_row)
 {
     $user = new self();
     $user->setObject($user_row);
     return $user;
 }
 /**
  * Change a particular configuration value
  *
  * @param string    $feature Feature
  * @param mixed     $value   Value
  * @param CMbObject $object  Host object
  *
  * @return null|string Store-like message
  */
 static function setConfig($feature, $value, CMbObject $object = null)
 {
     $where = array("feature" => "= '{$feature}'");
     if ($object) {
         $where["object_class"] = "= '{$object->_class}'";
         $where["object_id"] = "= '{$object->_id}'";
     } else {
         $where["object_class"] = "IS NULL";
         $where["object_id"] = "IS NULL";
     }
     $_config = new self();
     $_config->loadObject($where);
     $inherit = $value === self::INHERIT;
     if ($_config->_id && $inherit) {
         return $_config->delete();
     } elseif (!$inherit) {
         if ($object) {
             $_config->setObject($object);
         } else {
             $_config->object_id = null;
             $_config->object_class = null;
         }
         $_config->feature = $feature;
         $_config->value = $value;
         return $_config->store();
     }
     return null;
 }
 /**
  * Get a stock from a product and a host
  *
  * @param CProduct  $product Product
  * @param CMbObject $host    Host
  *
  * @return CProductStockService
  */
 static function getFromProduct(CProduct $product, CMbObject $host)
 {
     $stock = new self();
     $stock->setObject($host);
     $stock->product_id = $product->_id;
     $stock->loadMatchingObject();
     return $stock;
 }
 public static function initialize($route_row)
 {
     $route = new self();
     $route->setObject($route_row);
     return $route;
 }
Example #7
0
 /**
  * Prepare un acte NGAP vierge en vue d'être associé à un codable
  *
  * @param CCodable $codable Codable ciblé
  *
  * @return CActeNGAP
  */
 static function createEmptyFor(CCodable $codable)
 {
     $acte = new self();
     $acte->setObject($codable);
     $acte->quantite = 1;
     $acte->coefficient = 1;
     $acte->loadListExecutants();
     $acte->loadExecution();
     if ($acte->object_class == 'CConsultation' && $acte->_ref_object->sejour_id) {
         $sejour = $acte->_ref_object->loadRefSejour();
         $acte->prescripteur_id = $sejour->praticien_id;
     }
     return $acte;
 }
Example #8
0
 public function fromCache(array $cache)
 {
     $annotations = new self();
     foreach ($cache as $object => $ann) {
         $object = unserialize($object);
         $ann = array_map(function ($a) {
             return Annotation::fromCache($a);
         }, $ann);
         $obj = new self($ann);
         if ($object) {
             $obj->setObject($object);
         }
         $annotations->merge($obj);
     }
     return $annotations;
 }
 public static function initialize($row)
 {
     $object = new self();
     $object->setObject($row);
     return $object;
 }
Example #10
0
 /**
  * @param int $limit
  * @return self[]
  */
 public static function getForExport($limit = 3)
 {
     $db = MySQL::getInstance();
     $eventsArray = null;
     $query = "SELECT an.*, u.`email`, uf.`value` AS `nickname`, aloc.`locationData`,\n\t\t\t\tIF(`fromEventDate`='0000-00-00', `eventDate`, `fromEventDate`) AS `sortDate`,\n\t\t\t\tDATE_FORMAT( CURRENT_TIMESTAMP, '%Y-%m-%d 00:00:00' ) as `curStamp`\n                    \t\tFROM `announcements` an\n                    \t\t\tLEFT JOIN `users` AS `u` ON u.`id`=an.`user`\n                    \t\t\tLEFT JOIN `users_fields` AS `uf` ON uf.`id`=an.`user` AND uf.`name`='nickname'\n                    \t\t\tLEFT JOIN `anouncements_locations` AS `aloc` ON an.`location`=aloc.`id`\n                    \t\tWHERE an.`exported`=0 AND an.`visible`=1 AND an.`beginDate`<=NOW()\n                    \t\tORDER BY eventDate>=curStamp DESC,\n                    \t\t\tIF(eventDate>=curStamp,sortDate,''), sortDate DESC, priority DESC LIMIT " . intval($limit);
     $res = $db->fetch($query);
     if (!empty($res)) {
         // массивчик id'шников
         $idArray = [];
         foreach ($res as $k => $data) {
             $idArray[] = $data['id'];
         }
         $addData = Additionals::getByIdArray($idArray);
         foreach ($res as $k => $data) {
             $Event = new self();
             if (!empty($addData) && isset($addData[$data['id']]) && !empty($addData[$data['id']])) {
                 foreach ($addData[$data['id']] as $tmpaddData) {
                     $data['additionalData'][] = $tmpaddData;
                 }
             }
             if (isset($data['locationData']) && $data['locationData'] != '') {
                 $data['locationData'] = unserialize($data['locationData']);
             }
             $Event->setObject($data);
             $eventsArray[$data['id']] = $Event;
         }
     }
     return $eventsArray;
 }