Design Patterns PHP - Factory Method Java

1) What have we done?

We created abstract method "createProduct" - this is exactly the factory method from the name of this pattern
And adding to "Registry" we moved up to class "Creator"

abstract class Creator
{
    /**
     * @var Registry
     */
    protected $registry;

    function __construct(Registry $registry)
    {
        $this->registry = $registry;
    }

    public function getProduct()
    {
        $product = $this->createProduct();
        $this->registry->addProduct($product);

        return $product;
    }

    /**
     * @return Product
     */
    abstract function createProduct();
}

class Creator1 extends Creator
{
    /**
     * @return Product
     */
    function createProduct()
    {
        return new Product1();
    }
}

class Creator2 extends Creator
{
    /**
     * @return Product
     */
    function createProduct()
    {
        return new Product2();
    }
}




2) What are advantages?

- there was eliminated code duplication(adding to registry)
- we can easily get "Product" in client
- we don't have to know class names in class "Creator" so we can extend application in the future easily