/** * init module from data * * @param array $data * @return $this */ public function initFromData(array $data) { if (isset($data[$this->getEntityCode()])) { $this->addData($data[$this->getEntityCode()]); } $settings = $this->settingsFactory->create(); if (isset($data[$settings->getEntityCode()])) { $settings->setData($data[$settings->getEntityCode()]); $this->setSettings($settings); } $entitiesByIndex = []; if (isset($data['entity'])) { $entities = $data['entity']; if (is_array($entities)) { foreach ($entities as $key => $entityData) { if (!$entityData) { continue; } /** @var \Umc\Base\Model\Core\Entity $entity */ $entity = $this->entityFactory->create(); if (isset($entityData['attributes']) && is_array($entityData['attributes'])) { if (isset($entityData['attributes']['is_name'])) { $isName = $entityData['attributes']['is_name']; unset($entityData['attributes']['is_name']); if (isset($entityData['attributes'][$isName])) { $entityData['attributes'][$isName]['is_name'] = 1; } } foreach ($entityData['attributes'] as $attrKey => $attributeData) { /** @var \Umc\Base\Model\Core\Attribute $attribute */ $attribute = $this->attributeFactory->create(); $attribute->addData($attributeData); $attribute->setIndex($attrKey); $entity->addAttribute($attribute); } } unset($data['attribute']); $entity->addData($entityData); $entity->setIndex($key); $this->addEntity($entity); $entitiesByIndex[$key] = $entity; } } } if (isset($data['relation'])) { foreach ($data['relation'] as $index => $values) { foreach ($values as $jndex => $type) { if (isset($entitiesByIndex[$index]) && isset($entitiesByIndex[$jndex])) { /** @var \Umc\Base\Model\Core\Relation $relation */ $relation = $this->relationFactory->create(); $relation->setEntities($entitiesByIndex[$index], $entitiesByIndex[$jndex], $type); $this->addRelation($relation); } } } } return $this; }
private function getAFattrs() { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $attribute_factory = new AttributeFactory(); $results = array(); foreach (explode(',', $this->template->getAttrDisplayOrder()) as $attr) { $results[strtolower($attr)] = $attribute_factory->newAttribute($attr, array('values' => array()), $this->getServerID()); } return $results; }
/** * Add another attribute to this template * * @return int Attribute ID */ public function addAttribute($name, $value, $source = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } if (!is_array($value)) { debug_dump_backtrace('Value should be an array()', 1); } $server = $this->getServer(); # Initialise the Attribute Factory. $attribute_factory = new AttributeFactory(); # If there isnt a schema item for this attribute $attribute = $attribute_factory->newAttribute($name, $value, $server->getIndex(), $source); $attrid = $this->getAttrID($attribute->getName()); if (is_null($attrid)) { array_push($this->attributes, $attribute); } else { debug_dump_backtrace(sprintf('There was a request to add an attribute (%s), but it was already defined? (%s)', $attrid, __METHOD__), true); } if ($this->getID() == 'none') { usort($this->attributes, 'sortAttrs'); } return $attribute; }
/** * Add another attribute to this template * * @return int Attribute ID */ public function addAttribute($name, $value, $source = null) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } if (!is_array($value)) { debug_dump_backtrace('Value should be an array()', 1); } $server = $this->getServer(); # Initialise the Attribute Factory. $attribute_factory = new AttributeFactory(); if (preg_match('/;/', $name)) { system_message(array('title' => 'phpLDAPadmin doesnt support RFC3866.', 'body' => sprintf('%s {%s} (%s)', 'PLA might not do what you expect...', $name, is_array($value) ? serialize($value) : $value), 'type' => 'warn')); } # If there isnt a schema item for this attribute $attribute = $attribute_factory->newAttribute($name, $value, $server->getIndex(), $source); $attrid = $this->getAttrID($attribute->getName()); if (is_null($attrid)) { array_push($this->attributes, $attribute); } return $attribute; }
*/ /** */ require './common.php'; # The DN and OBJECTCLASS we are working with. $request = array(); $request['dn'] = get_request('dn', 'REQUEST', true); # Check if the entry exists. if (!$request['dn'] || !$app['server']->dnExists($request['dn'])) { error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php'); } $request['page'] = new TemplateRender($app['server']->getIndex(), get_request('template', 'REQUEST', false, null)); $request['page']->setDN($request['dn']); $request['page']->accept(true); $request['template'] = $request['page']->getTemplate(); $attribute_factory = new AttributeFactory(); # Grab the required attributes for the new objectClass $ldap = array(); $ldap['attrs']['must'] = array(); foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) { # Exclude "top" if its there. if (!strcasecmp('top', $oclass_name)) { continue; } if ($soc = $app['server']->getSchemaObjectClass($oclass_name)) { $ldap['attrs']['must'] = array_merge($ldap['attrs']['must'], $soc->getMustAttrNames(true)); } } $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']); /* Build a list of the attributes that this new objectClass requires, * but that the object does not currently contain */
/** * @return \Magento\Customer\Model\Attribute */ protected function _createCustomerAttribute() { return $this->_attributeFactory->create(); }
/** * Get available attributes */ public function getAvailAttrs() { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $attributes = array(); $server = $this->getServer(); # Initialise the Attribute Factory. $attribute_factory = new AttributeFactory(); if (in_array_ignore_case('extensibleobject', $this->getObjectClasses())) { foreach ($server->SchemaAttributes() as $sattr) { $attribute = $attribute_factory->newAttribute($sattr->getName(), array('values' => array()), $server->getIndex(), null); array_push($attributes, $attribute); } } else { $attrs = array(); foreach ($this->getObjectClasses() as $oc) { $soc = $server->getSchemaObjectClass($oc); $attrs = array_merge($attrs, $soc->getMustAttrNames(true), $soc->getMayAttrNames(true)); $attrs = array_unique($attrs); } foreach ($attrs as $attr) { if (is_null($this->getAttribute($attr))) { $attribute = $attribute_factory->newAttribute($attr, array('values' => array()), $server->getIndex(), null); array_push($attributes, $attribute); } } } masort($attributes, 'name'); return $attributes; }