main/app/API/Crud.php
public function copy($object, array $options = [])
    {
        $this->checkPermission('COPY', $object, [], true);
        $class = get_class($object);
        $new = new $class();

        $this->serializer->deserialize(
          $this->serializer->serialize($object),
          $new
        );

        $this->om->persist($new);

        //first event is the pre one
        if ($this->dispatch('copy', 'pre', [$object, $options, $new])) {
            //second event is the post one
            //we could use only one event afaik
            $this->dispatch('copy', 'post', [$object, $options, $new]);
        }

        $this->om->flush();

        return $new;
    }
public function copy($object, array $options = [])
    {
        $this->checkPermission('COPY', $object, [], true);
        $class = get_class($object);
        $new = new $class();

        $this->serializer->deserialize(
          $this->serializer->serialize($object),
          $new
        );

        $this->om->persist($new);

        //first event is the pre one
        if ($this->dispatch('copy', 'pre', [$object, $options, $new])) {
            //second event is the post one
            //we could use only one event afaik
            $this->dispatch('copy', 'post', [$object, $options, $new]);
        }

        $this->om->flush();

        return $new;
    }
public function copy ( $ object , array $ options = [ ] ) { $ this -> checkPermission ( 'COPY' , $ object , [ ] , true ) ; $ class = get_class ( $ object ) ; $ new = new $ class ( ) ; $ this -> serializer -> deserialize ( $ this -> serializer -> serialize ( $ object ) , $ new ) ; $ this -> om -> persist ( $ new ) ; //first event is the pre one if ( $ this -> dispatch ( 'copy' , 'pre' , [ $ object , $ options , $ new ] ) ) { //second event is the post one //we could use only one event afaik $ this -> dispatch ( 'copy' , 'post' , [ $ object , $ options , $ new ] ) ; } $ this -> om -> flush ( ) ; return $ new ; }
Copy an entry `object` of `class`.

@param object $object  - the entity to copy
@param array  $options - additional copy options
Copy an entry object of class .