/** * @param $object * @param $item * @param array $arguments * @param string $type * @param bool $isDefinedTest * @param bool $ignoreStrictCheck * @return mixed */ protected function getAttribute($object, $item, array $arguments = array(), $type = \Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) { $attribute = parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest); if (self::$recorder && is_object($object)) { self::$recorder->add($object); } return $attribute; }
public function test() { $collection = new ModelCollectionIdentifiers(array('Sonata\\PageBundle\\Tests\\Cache\\Invalidation\\Recorder_Model_1' => 'getCacheIdentifier')); $m1 = new Recorder_Model_1(); $m2 = new Recorder_Model_2(); $recorder = new Recorder($collection); $recorder->add($m1); $recorder->add($m2); $this->assertArrayHasKey('Sonata\\PageBundle\\Tests\\Cache\\Invalidation\\Recorder_Model_1', $recorder->get()); $this->assertArrayHasKey('Sonata\\PageBundle\\Tests\\Cache\\Invalidation\\Recorder_Model_2', $recorder->get()); $this->assertEquals(array('0' => 1), $recorder->get('Sonata\\PageBundle\\Tests\\Cache\\Invalidation\\Recorder_Model_1')); $recorder->reset(); $this->assertEquals(array(), $recorder->get('Sonata\\PageBundle\\Tests\\Cache\\Invalidation\\Recorder_Model_1')); }