How-To ====== .. _default-page-locator: Using DefaultPageLocator ------------------------ The default page locator uses the following strategy to locate pages: #. uppercases the first letter of each word and joining them to a CamelCase like class name #. prepending configured namespaces defined via :ref:`page_namespace_prefix ` #. returning first found class .. code-block:: php resolvePage('Login Page'); $page = new $page_class($page_factory); ... ?> Depending on existence either ``\shop\pages\LoginPage`` or ``\shop\account\pages\LoginPage`` will be returned. Defining a custom locator ------------------------- In some cases it might be necessary to build a custom page locator. For example to map page names to specific classes. .. literalinclude:: examples/custom_page_locator.php :linenos: Now it is possible to either locate the page manually by its name: .. code-block:: php resolvePage('Registration Page'); $registration_page = new $registration_page_class($page_factory); ... ?> or replace default locator with new one during ``PageFactory`` construction time. .. code-block:: php getPage('Registration Page'); ... ?>