/** * {@inheritDoc} */ public function onSlugCompletion(SluggableAdapter $ea, array &$config, $object, &$slug) { if (!$this->isInsert) { $options = $this->getOptions($object); $wrapped = AbstractWrapper::wrapp($object, $this->om); $meta = $wrapped->getMetadata(); $extConfig = $this->sluggable->getConfiguration($this->om, $meta->name); $config['useObjectClass'] = $extConfig['useObjectClass']; $target = $wrapped->getPropertyValue($config['slug']); $config['pathSeparator'] = $options['separator']; $ea->replaceRelative($object, $config, $target.$options['separator'], $slug); $uow = $this->om->getUnitOfWork(); // update in memory objects foreach ($uow->getIdentityMap() as $className => $objects) { // for inheritance mapped classes, only root is always in the identity map if ($className !== $wrapped->getRootObjectName()) { continue; } foreach ($objects as $object) { if (property_exists($object, '__isInitialized__') && !$object->__isInitialized__) { continue; } $oid = spl_object_hash($object); $objectSlug = $meta->getReflectionProperty($config['slug'])->getValue($object); if (preg_match("@^{$target}{$options['separator']}@smi", $objectSlug)) { $objectSlug = str_replace($target, $slug, $objectSlug); $meta->getReflectionProperty($config['slug'])->setValue($object, $objectSlug); $ea->setOriginalObjectProperty($uow, $oid, $config['slug'], $objectSlug); } } } } }