/** * Test getClientId returns 0 when no client has been set */ public function testGetClientIdForNonClient() { $id = Tools::getClientId(); $this->assertEquals(0, $id); }
/** * Obtain a mapping array that tells us which attribute name belongs to which id and vice versa * * @param integer|null|false $entityId * @throws Exception if entity id is not set * @return array|false */ public function getEntityAttributeMap($entityId = null) { $entityId = is_null($entityId) ? $this->entityId : $entityId; if ($this->entityId === false) { throw new Exception('No entity id available for ' . __METHOD__ . '()'); } if (isset(self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId])) { return self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId]; } $attributeList = $this->getEntityAttributeList('', $entityId); self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId] = array('id' => array(), 'name' => array()); if ($attributeList) { foreach ($attributeList as $k => $v) { self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId]['id'][$v['id']] = $v['attributeName']; self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId]['name'][$v['attributeName']] = $v['id']; self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName]['__ALL__'][$v['id']] = array('name' => $v['attributeName'], 'entity' => $v['entityId']); } } return self::$attributeDefinitionsMap[Tools::getClientId()][$this->cleanDefinitionsClassName][$entityId]; }