Example #1
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['TagInstance'][serialize($this->getPrimaryKey())])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['TagInstance'][serialize($this->getPrimaryKey())] = true;
     $keys = TagInstancePeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getTagId(), $keys[1] => $this->getTaggedItemId(), $keys[2] => $this->getModelName(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), $keys[5] => $this->getCreatedBy(), $keys[6] => $this->getUpdatedBy());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aTag) {
             $result['Tag'] = $this->aTag->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aUserRelatedByCreatedBy) {
             $result['UserRelatedByCreatedBy'] = $this->aUserRelatedByCreatedBy->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aUserRelatedByUpdatedBy) {
             $result['UserRelatedByUpdatedBy'] = $this->aUserRelatedByUpdatedBy->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), array('name' => 'required'));
     if ($validator->fails()) {
         return Response::json($validator->messages(), 400);
     }
     $tag = new Tag();
     $tag->name = Input::get('name');
     $tag->description = Input::get('description');
     $tag->save();
     return Response::json(array('success_code' => 'OK', 'data' => $tag->toArray()), 200);
 }
 public function tagData()
 {
     $oTag = TagQuery::create()->findPk($this->iTagId);
     if ($oTag === null) {
         $oTag = new Tag();
     }
     $aResult = $oTag->toArray();
     $aResult['CreatedInfo'] = Util::formatCreatedInfo($oTag);
     $aResult['UpdatedInfo'] = Util::formatUpdatedInfo($oTag);
     $aResult['tagged_models_and_items'] = array();
     foreach ($oTag->getTagInstances() as $oTagInstance) {
         $oCorrObject = $oTagInstance->getCorrespondingDataEntry();
         if ($oCorrObject) {
             $aResult['tagged_models_and_items'][] = array('name' => Util::nameForObject($oCorrObject), 'tagged_item_id' => $oTagInstance->getTaggedItemId(), 'model_name' => $oTagInstance->getModelName());
         } else {
             $oTagInstance->delete();
         }
     }
     return $aResult;
 }
Example #4
0
<?php

# Include autoloader
require_once 'vendor/autoload.php';
# Include config
require_once 'generated-conf/config.php';
$verse = find_verse('Genesis 1:4');
$keyword = find_keyword('Jealousy');
$type = find_tag_type('instructs regarding');
$tag = new Tag();
$tag->setKeyword($keyword)->setTagType($type)->setVerse($verse)->save();
var_dump($tag->toArray());
Example #5
0
 public function diff(Tag $tag, $matchSortOrder = false)
 {
     $diffArray = array();
     $tagArray = $tag->toArray();
     $matchArray = array('TagElement', 'TagSlug', 'TagRole', 'TagValue', 'TagValueDisplay');
     if ($matchSortOrder) {
         $matchArray[] = 'TagSortOrder';
     }
     foreach ($matchArray as $key) {
         //          error_log('COMPARE ['.$key.'] val1 = ['.$tagArray[$key].'] with val2 = ['.$this->fields[$key].']');
         if ((string) $tagArray[$key] !== (string) $this->fields[$key]) {
             //                error_log('Unmatched key: '.$key);
             $diffArray[] = $key;
         }
     }
     return $diffArray;
 }