Doctrine\ODM\PHPCR\UnitOfWork::removeTranslation PHP Метод

removeTranslation() публичный Метод

public removeTranslation ( object $document, string $locale )
$document object
$locale string
    public function removeTranslation($document, $locale)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::preRemoveTranslation)) {
            $this->eventListenersInvoker->invoke($class, Event::preRemoveTranslation, $document, new LifecycleEventArgs($document, $this->dm), $invoke);
        }
        $metadata = $this->dm->getClassMetadata(get_class($document));
        if (!$this->isDocumentTranslatable($metadata)) {
            return;
        }
        if (1 === count($this->getLocalesFor($document))) {
            throw new PHPCRException('The last translation of a translatable document may not be removed');
        }
        if ($document instanceof Proxy) {
            $document->__load();
        }
        $oid = spl_object_hash($document);
        $this->documentTranslations[$oid][$locale] = null;
        $this->setLocale($document, $metadata, null);
    }

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function removeTranslation($document, $locale)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $this->errorIfClosed();
     $this->unitOfWork->removeTranslation($document, $locale);
 }
UnitOfWork