Example #1
0
 public function testSameObject()
 {
     $c1 = DAO::faketory('compte');
     $c2 = DB_DataObject_Pluggable::retreiveFromRegistry('compte', $c1->id);
     $this->assertEquals($c1->id, $c2->id);
     $this->assertEquals($c1->ref, $c2->ref);
     $this->assertTrue($c1 === $c2);
 }
Example #2
0
 public function delete()
 {
     if ($ret = parent::delete()) {
         $this->addHistory('del');
         $this->getTag()->decrementCount();
         return $ret;
     }
     return false;
 }
Example #3
0
File: Tag.php Project: demental/m
 public function delete()
 {
     $nb = $this->nbTagged();
     if ($nb > 0) {
         trigger_error(__('Tag "%s" could not be deleted because %s records use it', array($this->__toString(), $nb)));
         return false;
     }
     return parent::delete();
 }
Example #4
0
 public function insert()
 {
     $this->date = date('Y-m-d H:i:s');
     return parent::insert();
 }
Example #5
0
 /**
  * Use ObjectRegistry
  */
 public function getLink($row, $table = null, $link = false)
 {
     //    return parent::getLink($row,$table,$link);
     if ($table === null) {
         $links = $this->links();
         if (is_array($links)) {
             if ($links[$row]) {
                 list($table, $link) = explode(':', $links[$row]);
                 if ($p = strpos($row, ".")) {
                     $row = substr($row, 0, $p);
                 }
                 return $this->getLink($row, $table, $link);
             }
             // $this->raiseError(
             //     "getLink: $row is not defined as a link (normally this is ok)",
             //     DB_DATAOBJECT_ERROR_NODATA);
             $r = false;
             return $r;
             // technically a possible error condition?
         }
         // use the old _ method - this shouldnt happen if called via getLinks()
         if (!($p = strpos($row, '_'))) {
             $r = null;
             return $r;
         }
         $table = substr($row, 0, $p);
         return $this->getLink($row, $table);
     }
     if (!isset($this->{$row})) {
         // $this->raiseError("getLink: row not set $row", DB_DATAOBJECT_ERROR_NODATA);
         return false;
     }
     if ($obj = DB_DataObject_Pluggable::retreiveFromRegistry($table, $this->{$row})) {
         return $obj;
     }
     $obj = parent::getLink($row, $table, $link);
     if (is_object($obj)) {
         DB_DataObject_Pluggable::storeToRegistry($obj);
     }
     return $obj;
 }
Example #6
0
File: db.php Project: demental/m
 protected static function _getTagFromTag($tag)
 {
     if (!is_a($tag, 'DataObjects_Tag')) {
         $t = DB_DataObject_Pluggable::retreiveFromRegistry('tag', 'strip', $tag);
         if ($t) {
             $tag = $t;
         } else {
             $t = DB_DataObject::factory('tag');
             $t->strip = $tag;
             if (!$t->find(true)) {
                 return false;
             }
             $tag = $t;
             DB_DataObject_Pluggable::storeToRegistry($tag);
         }
     }
     return $tag;
 }