Private API is extended

Edit on GitHub

Modules have public and private APIs. While public API updates always support backward compatibility, private API updates can break backward compatibility. So, backward compatibility is not guaranteed in the private API.

For more information about module APIs, see Definition of Module API.

Example of code that causes an upgradability error: Extending a private API form class

CustomerAccessForm extends Spryker\Zed\CustomerAccessGui\Communication\Form\CustomerAccessForm from a private API.

namespace Pyz\Zed\CustomerAccessGui\Communication\Form;

use Spryker\Zed\CustomerAccessGui\Communication\Form\CustomerAccessForm as SprykerCustomerAccessForm;

class CustomerAccessForm extends SprykerCustomerAccessForm
{
...
}
------------------------------------------------------------------------------------
"Please avoid dependency: ""Spryker\Zed\CustomerAccessGui\Communication\Form\CustomerAccessForm" in "Pyz\Zed\CustomerAccessGui\Communication\Form\CustomerAccessForm""
------------------------------------------------------------------------------------

Resolving the error: Extending a private API form class

To resolve the error provided in the example, try the following in the provided order:

  1. Recommended: Extend the functionality using the Configuration strategy.
  2. Recommended: Extend the functionality using the Plug and Play strategy.
  3. Recommended: Extend the functionality using the Project Modules strategy.
  4. Not recommended: Copy the functionality from the core to the project level:
    1. Register the missing extension point in Spryker Ideas, so we add it in future.
    2. Copy the private API core functionality to the project level and give it a unique name. For an example, see Example of resolving the error by copying the form class to the project level.
    3. As soon as the extension point in core is released, refactor the code added in step 4.2 using the strategies in steps 1-3. While it’s not refactored, auto-upgrades are not supported, and the effort to update the project may be bigger and require more manual work.

Example of resolving the error by copying the form class to the project level

<?php
namespace Pyz\Zed\CustomerAccessGui\Communication\Form;

use Spryker\Zed\Kernel\Communication\Form\AbstractType;

class PyzCustomerAccessForm extends AbstractType
{
    ...
}

After the fix re-evaluate the code. The same error shouldn’t be returned.

Example of code that causes an upgradability error: Extending a private API business model

CustomerAccessFilter extends Spryker\Zed\CustomerAccess\Business\CustomerAccess\CustomerAccessFilter from a private API.

namespace Pyz\Zed\CustomerAccess\Business\CustomerAccess;

use Spryker\Zed\CustomerAccess\Business\CustomerAccess\CustomerAccessFilter as SprykerCustomerAccessFilter;

class CustomerAccessFilter extends SprykerCustomerAccessFilter
{
    ...
}
------------------------------------------------------------------------------------
"PrivateApi:PrivateApiDependencyInBusinessModel: ""Spryker\Zed\CustomerAccess\Business\CustomerAccess\CustomerAccessFilter" in "Pyz\Zed\CustomerAccess\Business\CustomerAccess\CustomerAccessFilter""
------------------------------------------------------------------------------------

Example of resolving the error by copying the business model to the project level

<?php
namespace Pyz\Zed\CustomerAccess\Business\CustomerAccess;

class PyzCustomerAccessFilter implements PyzCustomerAccessFilterInterface
{
    ...
}

Example of code that causes an upgradability error: Extending a private API dependency provider

CheckoutPageDependencyProvider extends Spryker\Yves\CheckoutPage\CheckoutPageDependencyProvider from a private API.

namespace Pyz\Yves\CheckoutPage;

use Spryker\Yves\CheckoutPage\CheckoutPageDependencyProvider as SprykerCheckoutPageDependencyProvider;

class CheckoutPageDependencyProvider extends SprykerCheckoutPageDependencyProvider
{
    /**
     * ...
     */
    protected function getCustomerStepHandler(): ...
    {
        ...
    }
}
------------------------------------------------------------------------------------
"PrivateApi:MethodIsOverwritten: "Spryker\Yves\CheckoutPage\CheckoutPageDependencyProvider::getCustomerStepHandler" in "Pyz\Yves\CheckoutPage\CheckoutPageDependencyProvider""
------------------------------------------------------------------------------------

Example of resolving the error by copying the dependency provider to the project level

namespace Pyz\Yves\CheckoutPage;

use Spryker\Yves\CheckoutPage\CheckoutPageDependencyProvider as SprykerCheckoutPageDependencyProvider;

class CheckoutPageDependencyProvider extends SprykerCheckoutPageDependencyProvider
{
    /**
     * ...
     */
    protected function getPyzCustomerStepHandler(): ...
    {
        ...
    }
}

Example of code that causes an upgradability error: Extending a private API Bridge

namespace Pyz\Zed\PriceProduct\Dependency\Facade;

use Spryker\Zed\PriceProduct\Dependency\Facade\PriceProductToProductFacadeBridge as SprykerPriceProductToProductFacadeBridge;

class PriceProductToProductFacadeBridge extends SprykerPriceProductToProductFacadeBridge implements PriceProductToProductFacadeInterface
{
    ...
}
------------------------------------------------------------------------------------
Please avoid extension of the PrivateApi Spryker\Zed\PriceProduct\Dependency\Facade\PriceProductToProductFacadeBridge in Pyz\Zed\PriceProduct\Dependency\Facade\PriceProductToProductFacadeBridge
------------------------------------------------------------------------------------

Example of resolving the error: Extending a private API Bridge

Remove the Bridge.