Download the PHP package ang3/odoo-bundle without Composer
On this page you can find all versions of the php package ang3/odoo-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package odoo-bundle
Odoo bundle
This bundle is a Symfony integration of packages ang3/php-odoo-api-client and ang3/php-odoo-orm.
Main features:
- Client registry
- Object relational mapping (ORM)
- Debugging commands
- Record validator
Documentation of both packages:
Package | Documentation |
---|---|
ang3/php-odoo-api-client | https://github.com/Ang3/php-odoo-api-client |
ang3/php-odoo-orm | https://github.com/Ang3/php-odoo-orm |
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Configure your app
Create the file and paste the configuration below:
Finally, set needed vars to your project:
Work with multiple connections (optional)
You can add more connection under section . Here is an example for another connection:
The parameter is used to define the default connection to use.
Usage
Registry
If you want to work with all your configured clients, then you may want to get the registry. It stores all configured clients by connection name. You can get it by dependency injection:
The registry contains three useful methods:
- Set a client by connection name.
- Get the client of a connection. A is thrown if the connection was not found.
- Check if a connection exists by name.
If you don't use autowiring, you must pass the service as argument of your service:
Clients
It could be useful to get a client directly without working with the registry.
For example, the get the default client by autowiring, use the argument :
If the connection name is , then the autowired argument is .
- Run the command to get the list of autowired clients.
Of course if you don't use autowiring, you must pass the service as argument of your service:
For each client, the bundle creates a public alias following this naming convention: .
ORM
To enable ORM features, you must edit the file to configure it:
Usage
Get the manager of a connection easily by using dependency injection and autowiring:
If the connection name is , then the autowired argument is . By default, the default manager is autowired.
- Run the command to get the list of autowired managers.
Of course if you don't use autowiring, you must pass the service as argument of your service:
For each manager, the bundle creates a public alias following this naming convention: .
Please read the documentation of the ORM package ang3/php-odoo-orm to know more information about the object manager.
Validator
This bundle provides a useful validator according to the package symfony/validator to validate a record by ID, domains and/or connection. It resides to a basic annotation.
Here is an example of an object storing the ID of a company and invoice:
Here is the list of all options you can pass to the annotation:
- (required string) The model name of the record.
- (string) An expression which evaluation must returns valid client criteria.
- (string) the name of the connection to use
- By default the connection is used.
- (string) The error message if the value is not a positive integer
- By default the message is:
- (string) The message if the record was not found
- By default the message is:
As you can see, the validator uses both symfony/expression-language and the expression builder provided with the client. By this way, you can filter allowed records easily.
Here are the variable passed to the evaluated expression:
- the expression builder
- the object that the property/getter belongs to
- the user of the request
Upgrades & updates
v0.1.0 (beta-release)
- Client registry
- Beta ORM
- Registry
- Configuration
- Cache
- Record validator
All versions of odoo-bundle with dependencies
ang3/php-odoo-api-client Version ^6.1
ang3/php-odoo-orm Version ^0.1
symfony/cache Version >=4.2
symfony/console Version >=4.2
symfony/dependency-injection Version >=4.2
symfony/config Version >=4.2
symfony/http-kernel Version >=4.2
symfony/security-core Version >=4.2
symfony/validator Version >=4.2
symfony/expression-language Version >=4.2