public function save(AbstractEntity $entity) { if ($entity->getStorageStructure() == AbstractEntity::DOCUMENT) { $dm = new DocumentManager(); $document = $entity->toDocument(); $dm->persist($document); } if ($entity->getStorageStructure() == AbstractEntity::RELATIONAL) { $rm = new RecordManager(); $record = $entity->toRecord(); $rm->save($record); } }
/** * Build a new backup window instance * * @param \stdClass|array|null $parameters */ public function build($parameters) { if (is_null($parameters)) { return; } parent::build($parameters); }
/** * Sets the bean name. * * @param string $beanName * @throws Exception\InvalidBeanException */ public function setBeanName($beanName) { if (null !== $this->entityBeanName && $beanName != $this->entityBeanName) { throw new Exception\InvalidBeanException($beanName, $this->entityBeanName, $this); } parent::setBeanName($beanName); }
public function __construct() { parent::__construct(); $this->_name = ''; $this->_reportedBugs = new ArrayCollection(); $this->_assignedBugs = new ArrayCollection(); }
public function __construct() { parent::__construct(); $this->_description = ''; $this->_status = ''; $this->_products = new ArrayCollection(); }
/** * @return array * @throws \Exception */ public function getChangedProperties() { if (!$this->original) { throw new \Exception('No original snapshot taken'); } $diff = array_diff_assoc($this->getPropertiesAsArray(), $this->original->getPropertiesAsArray()); return $diff; }
/** * Create source adapter mock and set it into model object which tested in this class * * @param array $columns value which will be returned by method getColNames() * @return \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ protected function _createSourceAdapterMock(array $columns) { /** @var $source \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ $source = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Import\\AbstractSource', [], '', false, true, true, ['getColNames']); $source->expects($this->any())->method('getColNames')->will($this->returnValue($columns)); $this->_model->setSource($source); return $source; }
public function testConvertFieldName() { $fieldName = "intro_attended"; $this->assertEquals('getIntroAttended', AbstractEntity::convertFieldNameToGetterFunctionName($fieldName)); $fieldName = "status"; $this->assertEquals('getStatus', AbstractEntity::convertFieldNameToGetterFunctionName($fieldName)); $fieldName = "start_date_time"; $this->assertEquals('getStartDateTime', AbstractEntity::convertFieldNameToGetterFunctionName($fieldName)); }
public function __construct(array $data) { if (empty($data)) { return; } $photoSizes = $this->initPhotoSizesFromData($data); $this->setPhotoSizes($photoSizes); parent::__construct($data); }
/** * @param array $parameters */ public function build(array $parameters) { parent::build($parameters); foreach ($parameters as $property => $value) { if ('region' === $property && is_object($value)) { $this->region = new Region($value); } } }
/** * @param \stdClass|array $parameters */ public function build($parameters) { parent::build($parameters); foreach ($parameters as $property => $value) { if ('region' === $property) { $this->region = new Region($value); continue; } } }
/** * @param array $parameters */ public function build(array $parameters) { parent::build($parameters); foreach ($parameters as $property => $value) { switch ($property) { case 'region': if (is_object($value)) { $this->region = new Region($value); } unset($parameters[$property]); break; } } }
/** * @param AbstractEntity $entity * @param string $indention * @return string */ private function generateEntityMethods(AbstractEntity $entity, $indention) { $methodName = lcfirst($entity->methodNamePrefix() . ucfirst($entity->className())); $content = PHP_EOL . $indention . '/**' . PHP_EOL . $indention . ' * @return ' . $entity->className() . PHP_EOL . $indention . ' */' . PHP_EOL . $indention . 'public function ' . $methodName . '()' . PHP_EOL . $indention . '{' . PHP_EOL; if ($entity instanceof ObjectEntity) { $content .= $indention . $indention . 'return new ' . $entity->className() . '();' . PHP_EOL; } else { if ($entity instanceof QueryEntity) { $content .= $indention . $indention . 'return ' . $entity->className() . '::create();' . PHP_EOL; } } $content .= $indention . '}' . PHP_EOL; return $content; }
public function __construct() { parent::__construct(); $this->roles = new ArrayCollection(); }
public function __construct($gs) { parent::__construct(); $this->gString = $gs; }
public function updateStatus($status, $id) { if (in_array($status, array('in_progress', 'shipped', 'arrived'))) { return parent::update(array('status' => $status), $id); } }
public function getOneItem($id = null) { return parent::getRow($id); }
public function unblock($id) { return parent::update(array('is_blocked' => 'no'), $id); }
public function __construct() { parent::__construct(); $this->_id = 0; $this->_name = ''; }
/** * Adds meta data to the actual entity object. * * @param AbstractEntity $entity * @param mixed $resultRecord */ protected static function setEntityMeta(AbstractEntity $entity, $resultRecord) { if ($entity instanceof AbstractLocaleEntity) { $entity->addMeta($resultRecord->key, $resultRecord->value, $resultRecord->locale); } }
/** * @param array $parameters */ public function build(array $parameters) { foreach ($parameters as $property => $value) { switch ($property) { case 'networks': if (is_object($value)) { if (property_exists($value, 'v4')) { foreach ($value->v4 as $subProperty => $subValue) { $subValue->version = 4; $this->networks[] = new Network($subValue); } } if (property_exists($value, 'v6')) { foreach ($value->v6 as $subProperty => $subValue) { $subValue->version = 6; $subValue->cidr = $subValue->netmask; $subValue->netmask = null; $this->networks[] = new Network($subValue); } } } unset($parameters[$property]); break; case 'kernel': if (is_object($value)) { $this->kernel = new Kernel($value); } unset($parameters[$property]); break; case 'size': if (is_object($value)) { $this->size = new Size($value); } unset($parameters[$property]); break; case 'region': if (is_object($value)) { $this->region = new Region($value); } unset($parameters[$property]); break; case 'image': if (is_object($value)) { $this->image = new Image($value); } unset($parameters[$property]); break; case 'next_backup_window': $this->nextBackupWindow = new NextBackupWindow($value); unset($parameters[$property]); break; } } parent::build($parameters); if (is_array($this->features) && count($this->features)) { $this->backupsEnabled = in_array('backups', $this->features); $this->virtIOEnabled = in_array('virtio', $this->features); $this->privateNetworkingEnabled = in_array('private_networking', $this->features); $this->ipv6Enabled = in_array('ipv6', $this->features); } }
public function __toString() { $results = "(Contract " . parent::getId() . ")" . $this->name; return $results; }
$container = $is_modal ? 'admin_container' : 'our_content'; $before = 'toc'; $args = array('id' => $proposal_id, 'before' => $before, 'target' => $container, 'replace_target' => true); $proposal_nr = Proposal::getInstance()->getProposalById($proposal_id); if (!$proposal_nr) { jsonBadResult(t('This proposal was already deleted!'), $args); return; } $title = altPropertyValue($proposal_nr, 'title'); $state = altPropertyValue($proposal_nr, 'state'); if (!Groups::isOwner(_PROPOSAL_OBJ, $proposal_id)) { jsonBadResult(t('You can only delete your own proposals!'), $args); } elseif ($state == 'published') { jsonBadResult(t('We could not remove your proposal: It has already been published.'), $args); } else { $num_deleted = db_delete(tableName(_PROPOSAL_OBJ))->condition(AbstractEntity::keyField(_PROPOSAL_OBJ), $proposal_id)->execute(); if ($num_deleted) { // junk the proposal comments too ThreadedComments::getInstance()->removethreadsForEntity($proposal_id, _PROPOSAL_OBJ); $args['before'] = ''; jsonGoodResult(TRUE, tt('You have removed the proposal %1$s', $title), $args); } else { jsonBadResult(t('We could not remove your proposal'), $args); } } } else { jsonBadResult(t('No proposal identifier submitted!'), $args); } break; case 'save_public': // no break so that the request filters down to 'save'
public function __construct($data = array(), &$doorGets = null, $joinMaps = array()) { parent::__construct($data, $doorGets, $joinMaps); }
protected function convert(array $data) : array { $data = parent::convert($data); if (!empty($data['annotations'])) { $data['annotations'] = $this->convertAnnotations($data['annotations']); } if (!empty($data['upload_date']) && ($date = \DateTime::createFromFormat('Ymd', $data['upload_date']))) { $data['upload_date'] = $date; } return $data; }
/** * Returns this Price as an associative array. * * @return array */ public function toArray() { $array = parent::toArray(); $array['amount'] = $this->amount; $array['currencyCode'] = $this->currencyCode; $array['formattedPrice'] = $this->formattedPrice; return $array; }
/** * Returns true if value can be converted into domain model instance * @param AbstractEntity $entity * @param stdClass $value * @return boolean */ private function isMorhing($entity, $value) { if (!$entity instanceof Serialization\ObjectEntity) { return false; } //String, numeric are fine if (!is_object($value)) { return false; } // if object has same type already (it's wierd, but ok) if (get_class($value) === $entity->getType()) { return false; } // we expect stdClass here only if (!$value instanceof \stdClass) { return false; } return true; }
public function add($request) { unset($request['id']); return parent::insert($request); }
/** * @param AbstractEntity $entity * @param array $array */ protected function mapEntityFromArray(AbstractEntity $entity, array $array) { $entity->setPropertiesFromArray($array); }
function showProjectPage($show_last = FALSE, $owner_only = false) { global $base_url; //TODO check for the role of current user $role = getRole(); if (!Users::isMentor()) { //true for both mentors and organisation admins. Also, they will see their own stuff only echo t('You are not allowed to see the projects in this view.'); return; } //Get my groups $my_organisations = Groups::getGroups(_ORGANISATION_GROUP); if (!$my_organisations->rowCount()) { //There are no organisations yet for this user if ($role == _ORGADMIN_TYPE) { echo t('You have no organisation yet.') . '<br/>'; echo "<a href='" . _WEB_URL . "/dashboard/organisation/administer'>" . t('Please go to the organisation register page') . "</a>"; } else { echo t('You are not connected to any organisation yet.') . '<br/>'; echo "<a href='" . _WEB_URL . "/user/" . Users::getMyId() . "/edit'>" . t('Please edit your account to connect') . "</a>"; } } else { $show_all = !(bool) $owner_only; $owner_id = $GLOBALS['user']->uid; $orgs = array(); $orgids = array(); foreach ($my_organisations as $org) { $orgs[] = $org; $orgids[] = $org->org_id; } $projects = Project::getProjectsByUser($owner_id, $orgids, $show_all); //$my_organisations->fetchCol()); if (!$projects) { echo $owner_only ? t('You have no project yet registered') : t('There are no projects yet registered.'); echo $owner_only ? "<BR>" . '<a href="' . $base_url . '/dashboard/projects/administer" ' . 'title="Manage all my organisation\'s projects">Manage all my organisation\'s projects</a>' : ''; echo '<h2>' . t('Add a project') . '</h2>'; $tab_prefix = 'project_page-'; $target = "{$tab_prefix}1"; $form = drupal_get_form("vals_soc_project_form", '', 'project_page-1'); $form['submit'] = ajax_pre_render_element($form['submit']); $add_tab = renderForm($form, $target, true); $data = array(); $data[] = array(1, 'Add', 'add', _PROJECT_OBJ, '0', "target=admin_container", true, 'adding from the right'); echo renderTabs(1, null, 'project_page-', _PROJECT_OBJ, $data, null, TRUE, $add_tab, 1, _PROJECT_OBJ); ?> <script type="text/javascript"> transform_into_rte(); activatetabs('tab_', ['project_page-1']); </script><?php } else { echo "<a href='" . _WEB_URL . "/dashboard/projects/administer'>" . t('Show all') . "</a>"; echo " | "; echo "<a href='" . _WEB_URL . "/dashboard/projects/administer/mine'>" . t('Show only mine') . "</a>"; $org = 1; $show_org_title = $my_organisations->rowCount() > 1; $org_key = AbstractEntity::keyField(_ORGANISATION_GROUP); foreach ($orgs as $organisation) { $projects = Project::getProjectsByUser($owner_id, array($organisation->{$org_key}), $show_all); showOrganisationProjects($org, $projects, $organisation, $show_org_title, $show_last, TRUE, $owner_only); $org++; } } } }