Download the PHP package locustv2/yii2-linkable-behavior without Composer
On this page you can find all versions of the php package locustv2/yii2-linkable-behavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-linkable-behavior
Linkable Behavior for Yii2 Components
This extension help creating urls easier in yii2. This behavior provides support for components that have a page to display its contents. The page can be an action in a Module or simply in a Controller. It will be easier to get links related to this record without having to write Url Route over and over again.
Installation
The preferred way to install the library is through composer.
Either run
or add
to your composer.json
file.
Usage
Add the behavior to your ActiveRecord that can he hotlinked:
With that code in place, you can now use 4 available methods in your User
and Photo
ActiveRecord:
getUrlRoute($action = null, array $params = [])
getUrlRouteTo(Component $component, $action = null)
getHotlink($action = null, array $params = [], array $options = [])
getHotlinkTo(Component $component, $action = null, array $params = [], array $options = [])
Examples (assuming that you use pretty urls)
getUrlRoute($action = null, array $params = [])
getUrlRouteTo(Component $component, $action = null)
getHotlink($action = null, array $params = [], array $options = [])
If you want to use absolute urls, you should set LinkableBehavior::$useAbsoluteUrl
to true
.
If you want to disable hotlinks, you should set LinkableBehavior::$disableHotlink
to true
. <span/>
will be used instead of <a/>
getHotlinkTo(Component $component, $action = null, array $params = [], array $options = [])
To do
- Add unit tests
Contributing
Feel free to send pull requests.
License
For license information check the LICENSE-file.