/** * Creates a new discovery. * * @param KeyValueStore $store The key-value store used to * store the bindings and the * binding types. * @param BindingInitializer[] $initializers The binding initializers to * apply to newly created or * unserialized bindings. */ public function __construct(KeyValueStore $store, array $initializers = array()) { parent::__construct($initializers); $this->store = $store; $this->keysByTypeName = $store->get('::keysByTypeName', array()); $this->nextKey = $store->get('::nextKey', 0); }
/** * Creates a new resource discovery. * * @param string $path The path to the JSON file. * @param BindingInitializer[] $initializers The binding initializers to * apply to newly created or * unserialized bindings. */ public function __construct($path, array $initializers = array()) { Assert::stringNotEmpty($path, 'The path to the JSON file must be a non-empty string. Got: %s'); parent::__construct($initializers); $this->path = $path; $this->encoder = new JsonEncoder(); $this->encoder->setPrettyPrinting(true); $this->encoder->setEscapeSlash(false); }
/** * {@inheritdoc} */ protected function removeBindingsByQueryAndType($query, $typeName, array $parameterValues = null) { parent::removeBindingsByQueryAndType($query, $typeName, $parameterValues); $this->store->set('//typeIndex', $this->typeIndex); $this->store->set('//queryIndex', $this->queryIndex); }
/** * {@inheritdoc} */ public function clear() { parent::clear(); $this->types = array(); $this->bindings = array(); $this->nextId = 0; }