src/Pool.php
public function &produce($type, array $attributes = null, $save = true)
    {
        $registered_type = $this->requireRegisteredType($type);

        $object = $this->getProducerForRegisteredType($registered_type)->produce($type, $attributes, $save);

        if ($object instanceof EntityInterface) {
            if ($object->isLoaded()) {
                $this->objects_pool[$registered_type][$object->getId()] = $object;
            }

            return $object;
        } else {
            throw new RuntimeException("Failed to produce an instance of '$type'");
        }
    }
public function &produce($type, array $attributes = null, $save = true)
    {
        $registered_type = $this->requireRegisteredType($type);

        $object = $this->getProducerForRegisteredType($registered_type)->produce($type, $attributes, $save);

        if ($object instanceof EntityInterface) {
            if ($object->isLoaded()) {
                $this->objects_pool[$registered_type][$object->getId()] = $object;
            }

            return $object;
        } else {
            throw new RuntimeException("Failed to produce an instance of '$type'");
        }
    }
Produce new instance of $type.

@param  string          $type
@param  array|null      $attributes
@param  bool            $save
@return EntityInterface