Download the PHP package angelxmoreno/cakephp-linked-entities without Composer
On this page you can find all versions of the php package angelxmoreno/cakephp-linked-entities. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download angelxmoreno/cakephp-linked-entities
More information about angelxmoreno/cakephp-linked-entities
Files in angelxmoreno/cakephp-linked-entities
Package cakephp-linked-entities
Short Description LinkedEntities plugin for CakePHP 3.x
License MIT
Homepage https://github.com/angelxmoreno/cakephp-linked-entities
Informations about the package cakephp-linked-entities
LinkedEntities plugin for CakePHP 3.x
LinkedEntities allows the ability to associate your User Entities with any other Entities ( including self referencing ) by a category type. It adds shortcut functions to your User Table for ease of use.
Features
- Ability to define User-to-Entity relationship via a polymorphic table
- Define relationship by category
- Automatic relationship of Entity-to-User
- Shortcut methods based on relationship name
Examples
Requirements
- CakePHP 3.x
- PHP >=5.6
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
Next you need to load the plugin by adding the following to your config/bootstrap.php
file:
Finally, create the required tables using cakephp/migrations
:
Or import the sql schema found in config/schema
.
Setup
- In your
config/app.php
define a new config key calledLinkedEntities
( see configuration ) -
In your UsersTable add the
LinkedEntities.LinkableEntityUser
behavior like so: - Optionally add the
LinkedEntities.LinkableEntity
behavior to the corresponding Table classes defined in your config. i.e:
Configuration
Sample configuration:
With the configuration above ( after adding the behavior ) you will have 6 new methods available to your UsersTable:
- $this->Users->addStarredProjects($user, $project);
- $this->Users->removeStarredProjects($user, $project);
- $this->Users->addFollowedProjects($user, $project);
- $this->Users->removeFollowedProjects($user, $project);
- $this->Users->addFollowedUsers($user, $otherUser);
- $this->Users->removeFollowedUsers($user, otherUser);
UserModel parameter
A string defining the plugin.name of your UsersTable ( defaults to Users
)
link_types
An array as a int => string ( this saves the int provided under the table column type
)
links
An array as relationship name => settings Settings have the following keys
- name: The name of the relationship from the perspective of the linked entity ( the reverse relationship name )
- className: The name of the table to associate the user to
- linkType: the int value corresponding to one of the defined
link_types
Reporting Issues
If you have a problem with the plugin please open an issue on GitHub.
License
This plugin is offered under an MIT license.