Пример #1
0
 /** Get all values for a property
  * This method will return an empty array if the property does not exist.
  *
  * @param string $property The name of the property (e.g. foaf:name)
  * @param string $type     The type of value to filter by (e.g. literal)
  * @param string $lang     The language to filter by (e.g. en)
  *
  * @return array An array of values associated with the property
  */
 public function all($property, $type = null, $lang = null)
 {
     list($first, $rest) = $this->split($property);
     $result = parent::all($property, $type, $lang);
     if (is_array($result)) {
         $llResult = array();
         foreach ($result as $res) {
             if ($res instanceof self && !empty($this->_rm)) {
                 if ($this->_rm->getUnitOfWork()->isManaged($res)) {
                     $llResult[] = $this->_rm->getUnitOfWork()->retrieveResource($res->getUri());
                 } else {
                     $resLazyLoad = $this->_rm->find($res->getUri());
                     $llResult[] = $resLazyLoad ? $resLazyLoad : $res;
                 }
             } else {
                 if ($res instanceof Literal) {
                     $llResult[] = $res;
                 }
             }
         }
         return $llResult;
     } else {
         if ($this->_rm->isResource($result)) {
             try {
                 if ($result->isBNode()) {
                     $re = $this->_rm->getUnitOfWork()->getPersister()->constructBNode($this->uri, $first);
                 } else {
                     $re = $this->_rm->find($result->getUri());
                 }
                 if (!empty($re)) {
                     if ($rest === '') {
                         return $re;
                     }
                     return $re->all($rest, $type, $lang);
                 }
                 return $re;
             } catch (Exception $e) {
                 return $e->getMessage();
             }
         } else {
             return $result;
         }
     }
 }