public function importValue($value) { if ($value instanceof UnifiedContainer) { if ($value->isLazy()) { return $this->import([$this->name => $value->getList()]); } elseif ($value->getParentObject()->getId() && ($list = $value->getList())) { return $this->import([$this->name => ArrayUtils::getIdsArray($list)]); } else { return parent::importValue(null); } } if (is_array($value)) { try { if ($this->scalar) { Assert::isScalar(current($value)); } else { Assert::isInteger(current($value)); } return $this->import([$this->name => $value]); } catch (WrongArgumentException $e) { return $this->import([$this->name => ArrayUtils::getIdsArray($value)]); } } return parent::importValue($value); }
public function importValue($value) { if (is_array($value)) { try { Assert::isScalar(current($value)); return $this->import(array($this->name => $value)); } catch (WrongArgumentException $e) { return $this->import(array($this->name => ArrayUtils::getIdsArray($value))); } } return parent::importValue($value); }
protected function checkNumber($number) { if ($this->scalar) { Assert::isScalar($number); } else { Assert::isInteger($number); } }
public function getById($id, $expires = Cache::EXPIRES_MEDIUM) { Assert::isScalar($id); Assert::isNotEmpty($id); if (isset($this->identityMap[$id])) { return $this->identityMap[$id]; } return $this->addObjectToMap(Cache::worker($this)->getById($id, $expires)); }