Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Cookbook - How to add a custom Model? #6226

Merged
merged 2 commits into from
Sep 30, 2016

Conversation

CoderMaggie
Copy link
Member

@CoderMaggie CoderMaggie commented Sep 27, 2016

Q A
Doc fix? no
New docs? yes
BC breaks? no
Related tickets partially #5275
License MIT

@CoderMaggie CoderMaggie changed the title [Documentation] Cookbook - How to add a custom Model? [WIP] [Documentation] Cookbook - How to add a custom Model? Sep 27, 2016
@pjedrzejewski pjedrzejewski added the Documentation Documentation related issues and PRs - requests, fixes, proposals. label Sep 27, 2016
In some cases you may be needing to add new models to your application in order to cover unique business needs.
The proccess of extending Sylius with new entities is simple and intuitive.

As an example we will take a **Supplier entity**, which may be really useful for th shop maintenance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

th => the? Also still works if you just remove it entirely.

3. Update the database using migrations
---------------------------------------

Assuming that you have the databease updated to the state before adding the new entity you should run:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo error : 'databease' should be 'database'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'm not a native English speaker but I would turn this phrase into :
Assuming that your database was up-to-date before adding the new entity, run:

If a native English speaker could correct me ;-)

@CoderMaggie CoderMaggie changed the title [WIP] [Documentation] Cookbook - How to add a custom Model? [Documentation] Cookbook - How to add a custom Model? Sep 28, 2016
.. code-block:: yaml

# app/config/routing/admin/admin.yml
sylius_admin_carousel_item:
Copy link
Member

@GSadee GSadee Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should be app_admin_supplier

Copy link
Member

@pjedrzejewski pjedrzejewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing:

  • Stuff from comments;
  • How to add it to the admin menu.

.. image:: ../_images/container_debug_supplier.png
:align: center

6. Use Sylius API to create new resource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that this step is optional. (using the API)


.. tip::

Read more about authorizing in API :doc:`here </api/authorization>`. Different requests to Sylius API are described in `the Lionframe docs <http://lakion.com/lionframe>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add examples of getting a list of suppliers and partial update of a supplier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I wasn't sure. API is not the main issue of this cookbook.


# app/config/routing.yml
app_admin:
resource: 'routing/admin/admin.yml'
Copy link
Member

@pjedrzejewski pjedrzejewski Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main admin routing file should be just routing/admin.yml.


.. tip::

To see what you can do with your new entity access the ``http://localhost:8000/admin/suppliers`` url.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ missing at the end.

driver:
name: doctrine/orm
options:
class: AppBundle/Entity/Supplier

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be backslashes instead of slashes -> AppBundle\Entity\Supplier

@pjedrzejewski pjedrzejewski merged commit f0993c6 into Sylius:master Sep 30, 2016
@pjedrzejewski
Copy link
Member

Nice work Magda, thank you! :)

@CoderMaggie CoderMaggie deleted the docs/cookbook/model branch January 17, 2017 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation related issues and PRs - requests, fixes, proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants