Example #1
0
 public function __construct($key = null, $salt = null)
 {
     if (is_string($key) && preg_match('/^([a-z0-9]+)[a-f0-9]{32}$/i', $key, $matches)) {
         $id = base_convert($matches[1], 36, 10);
         $key = $this->generateSlug($id, $salt) == $key ? $id : null;
     }
     return parent::__construct($key);
 }
Example #2
0
 public function __construct($key = null)
 {
     if (is_object($key) && isset($key->post_type)) {
         if ($key->post_type != 'wpt_test') {
             $this->values['ID'] = null;
             return;
         }
         $postAsArray = (array) $key;
         unset($postAsArray['ancestors']);
         unset($postAsArray['filter']);
         unset($postAsArray['format_content']);
         return parent::__construct(new ArrayIterator(array($postAsArray)));
     }
     return parent::__construct($key);
 }