-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
CoderMaggie
commented
Sep 27, 2016
•
edited
Loading
edited
Q | A |
---|---|
Doc fix? | no |
New docs? | yes |
BC breaks? | no |
Related tickets | partially #5275 |
License | MIT |
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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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 ;-)
1f54ae1
to
2e8f9d4
Compare
.. code-block:: yaml | ||
|
||
# app/config/routing/admin/admin.yml | ||
sylius_admin_carousel_item: |
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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>`_. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/
missing at the end.
2e8f9d4
to
888557a
Compare
driver: | ||
name: doctrine/orm | ||
options: | ||
class: AppBundle/Entity/Supplier |
There was a problem hiding this comment.
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
888557a
to
b964b78
Compare
Nice work Magda, thank you! :) |