Permalink
Browse files

New Crowdin translations (#1555)

* New translations introduction.md (Polish)

* New translations loader.md (Polish)

* New translations db-models-metadata.md (Polish)

* New translations db-models-cache.md (Polish)

* New translations Phalcon_Validation_Validator_Date.md (Polish)

* New translations Phalcon_Version.md (Polish)

* New translations Phalcon_Validation_Validator_Digit.md (Polish)

* New translations Phalcon_Validation_Validator_Email.md (Polish)

* New translations Phalcon_Validation_Validator_Exception.md (Polish)

* New translations Phalcon_Validation_Validator_ExclusionIn.md (Polish)

* New translations Phalcon_Validation_Validator_File.md (Polish)

* New translations Phalcon_Validation_Validator_Identical.md (Polish)

* New translations Phalcon_Validation_Validator_InclusionIn.md (Polish)

* New translations Phalcon_Validation_Validator_Numericality.md (Polish)

* New translations Phalcon_Validation_Validator_PresenceOf.md (Polish)

* New translations Phalcon_Validation_Validator_Regex.md (Polish)

* New translations Phalcon_Validation_Validator_StringLength.md (Polish)

* New translations Phalcon_Validation_Validator_Uniqueness.md (Polish)

* New translations Phalcon_Validation_Validator_Url.md (Polish)

* New translations acl.md (Polish)

* New translations db-models-behaviors.md (Polish)

* New translations annotations.md (Polish)

* New translations application-cli.md (Polish)

* New translations application-micro.md (Polish)

* New translations assets.md (Polish)

* New translations cache.md (Polish)

* New translations config.md (Polish)

* New translations contributions.md (Polish)

* New translations controllers.md (Polish)

* New translations crypt.md (Polish)

* New translations db-layer.md (Polish)

* New translations db-migrations.md (Polish)

* New translations Phalcon_Mvc_View.md (Polish)

* New translations Phalcon_Mvc_User_Module.md (Polish)

* New translations Phalcon_Mvc_Micro_Exception.md (Polish)

* New translations Phalcon_Mvc_Collection_Manager.md (Polish)

* New translations Phalcon_Mvc_Collection_ManagerInterface.md (Polish)

* New translations Phalcon_Mvc_Controller.md (Polish)

* New translations Phalcon_Mvc_Controller_BindModelInterface.md (Polish)

* New translations Phalcon_Mvc_Dispatcher.md (Polish)

* New translations Phalcon_Mvc_DispatcherInterface.md (Polish)

* New translations Phalcon_Mvc_Dispatcher_Exception.md (Polish)

* New translations Phalcon_Mvc_EntityInterface.md (Polish)

* New translations Phalcon_Mvc_Micro.md (Polish)

* New translations Phalcon_Mvc_Micro_Collection.md (Polish)

* New translations Phalcon_Mvc_Micro_CollectionInterface.md (Polish)

* New translations Phalcon_Mvc_Micro_LazyLoader.md (Polish)

* New translations Phalcon_Mvc_Collection_Document.md (Polish)

* New translations Phalcon_Mvc_Micro_MiddlewareInterface.md (Polish)

* New translations Phalcon_Mvc_Model.md (Polish)

* New translations Phalcon_Mvc_ModelInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Behavior.md (Polish)

* New translations Phalcon_Mvc_Model_BehaviorInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Behavior_SoftDelete.md (Polish)

* New translations Phalcon_Mvc_Model_Behavior_Timestampable.md (Polish)

* New translations Phalcon_Mvc_Model_Binder.md (Polish)

* New translations Phalcon_Mvc_Model_BinderInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Binder_BindableInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Criteria.md (Polish)

* New translations Phalcon_Mvc_Model_CriteriaInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Exception.md (Polish)

* New translations Phalcon_Mvc_Collection_Exception.md (Polish)

* New translations Phalcon_Mvc_Collection_Behavior_Timestampable.md (Polish)

* New translations Phalcon_Mvc_Model_ManagerInterface.md (Polish)

* New translations Phalcon_Logger_Exception.md (Polish)

* New translations Phalcon_Image_Adapter_Imagick.md (Polish)

* New translations Phalcon_Image_Exception.md (Polish)

* New translations Phalcon_Kernel.md (Polish)

* New translations Phalcon_Loader.md (Polish)

* New translations Phalcon_Loader_Exception.md (Polish)

* New translations Phalcon_Logger_Adapter.md (Polish)

* New translations Phalcon_Logger_AdapterInterface.md (Polish)

* New translations Phalcon_Logger_Adapter_File.md (Polish)

* New translations Phalcon_Logger_Adapter_Firephp.md (Polish)

* New translations Phalcon_Logger_Adapter_Stream.md (Polish)

* New translations Phalcon_Logger_Adapter_Syslog.md (Polish)

* New translations Phalcon_Logger_Formatter.md (Polish)

* New translations Phalcon_Mvc_Collection_Behavior_SoftDelete.md (Polish)

* New translations Phalcon_Logger_FormatterInterface.md (Polish)

* New translations Phalcon_Logger_Formatter_Firephp.md (Polish)

* New translations Phalcon_Logger_Formatter_Json.md (Polish)

* New translations Phalcon_Logger_Formatter_Line.md (Polish)

* New translations Phalcon_Logger_Formatter_Syslog.md (Polish)

* New translations Phalcon_Logger_Item.md (Polish)

* New translations Phalcon_Logger_Multiple.md (Polish)

* New translations Phalcon_Mvc_Application.md (Polish)

* New translations Phalcon_Mvc_Application_Exception.md (Polish)

* New translations Phalcon_Mvc_Collection.md (Polish)

* New translations Phalcon_Mvc_CollectionInterface.md (Polish)

* New translations Phalcon_Mvc_Collection_Behavior.md (Polish)

* New translations Phalcon_Mvc_Collection_BehaviorInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Manager.md (Polish)

* New translations Phalcon_Mvc_Model_Message.md (Polish)

* New translations Phalcon_Mvc_User_Component.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_StringLength.md (Polish)

* New translations Phalcon_Mvc_Model_Transaction_Manager.md (Polish)

* New translations Phalcon_Mvc_Model_Transaction_ManagerInterface.md (Polish)

* New translations Phalcon_Mvc_Model_ValidationFailed.md (Polish)

* New translations Phalcon_Mvc_Model_Validator.md (Polish)

* New translations Phalcon_Mvc_Model_ValidatorInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Email.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Exclusionin.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Inclusionin.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Ip.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Numericality.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_PresenceOf.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Regex.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Uniqueness.md (Polish)

* New translations Phalcon_Mvc_Model_Transaction_Exception.md (Polish)

* New translations Phalcon_Mvc_Model_Validator_Url.md (Polish)

* New translations Phalcon_Mvc_ModuleDefinitionInterface.md (Polish)

* New translations Phalcon_Mvc_Router.md (Polish)

* New translations Phalcon_Mvc_RouterInterface.md (Polish)

* New translations Phalcon_Mvc_Router_Annotations.md (Polish)

* New translations Phalcon_Mvc_Router_Exception.md (Polish)

* New translations Phalcon_Mvc_Router_Group.md (Polish)

* New translations Phalcon_Mvc_Router_GroupInterface.md (Polish)

* New translations Phalcon_Mvc_Router_Route.md (Polish)

* New translations Phalcon_Mvc_Router_RouteInterface.md (Polish)

* New translations Phalcon_Mvc_Url.md (Polish)

* New translations Phalcon_Mvc_UrlInterface.md (Polish)

* New translations Phalcon_Mvc_Url_Exception.md (Polish)

* New translations Phalcon_Mvc_Model_Transaction_Failed.md (Polish)

* New translations Phalcon_Mvc_Model_TransactionInterface.md (Polish)

* New translations Phalcon_Mvc_Model_MessageInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Query.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData.md (Polish)

* New translations Phalcon_Mvc_Model_MetaDataInterface.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Apc.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Files.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Libmemcached.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Memcache.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Memory.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Redis.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Session.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_StrategyInterface.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Strategy_Annotations.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Strategy_Introspection.md (Polish)

* New translations Phalcon_Mvc_Model_MetaData_Xcache.md (Polish)

* New translations Phalcon_Mvc_Model_QueryInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Transaction.md (Polish)

* New translations Phalcon_Mvc_Model_Query_Builder.md (Polish)

* New translations Phalcon_Mvc_Model_Query_BuilderInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Query_Lang.md (Polish)

* New translations Phalcon_Mvc_Model_Query_Status.md (Polish)

* New translations Phalcon_Mvc_Model_Query_StatusInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Relation.md (Polish)

* New translations Phalcon_Mvc_Model_RelationInterface.md (Polish)

* New translations Phalcon_Mvc_Model_ResultInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Resultset.md (Polish)

* New translations Phalcon_Mvc_Model_ResultsetInterface.md (Polish)

* New translations Phalcon_Mvc_Model_Resultset_Complex.md (Polish)

* New translations Phalcon_Mvc_Model_Resultset_Simple.md (Polish)

* New translations Phalcon_Mvc_Model_Row.md (Polish)

* New translations mvc.md (Polish)

* New translations tutorial-invo.md (Polish)

* New translations queue.md (Polish)

* New translations request.md (Polish)

* New translations routing.md (Polish)

* New translations security.md (Polish)

* New translations sidebar.md (Polish)

* New translations tag.md (Polish)

* New translations tutorial-base.md (Polish)

* New translations tutorial-rest.md (Polish)

* New translations tutorial-vokuro.md (Polish)

* New translations validation.md (Polish)

* New translations views.md (Polish)

* New translations volt.md (Polish)

* New translations tutorial-base.md (Spanish)

* New translations db-layer.md (Spanish)

* New translations db-odm.md (Spanish)

* New translations volt.md (Spanish)

* New translations Phalcon_Acl_AdapterInterface.md (Spanish)

* New translations Phalcon_Acl_Adapter_Memory.md (Spanish)

* New translations Phalcon_Annotations_Collection.md (Spanish)

* New translations Phalcon_Acl_Resource.md (Spanish)

* New translations Phalcon_Acl_ResourceAware.md (Spanish)

* New translations Phalcon_Acl_ResourceInterface.md (Spanish)

* New translations Phalcon_Acl_Role.md (Spanish)

* New translations Phalcon_Acl_RoleAware.md (Spanish)

* New translations Phalcon_Acl_RoleInterface.md (Spanish)

* New translations Phalcon_Annotations_Adapter.md (Spanish)

* New translations Phalcon_Annotations_AdapterInterface.md (Spanish)

* New translations Phalcon_Annotations_Adapter_Apc.md (Spanish)

* New translations Phalcon_Annotations_Adapter_Files.md (Spanish)

* New translations Phalcon_Annotations_Adapter_Memory.md (Spanish)

* New translations Phalcon_Annotations_Adapter_Xcache.md (Spanish)

* New translations Phalcon_Annotations_Annotation.md (Spanish)

* New translations Phalcon_Annotations_Reader.md (Spanish)

* New translations Phalcon_Annotations_ReaderInterface.md (Spanish)

* New translations Phalcon_Annotations_Reflection.md (Spanish)

* New translations Phalcon_Application.md (Spanish)

* New translations environments-nanobox.md (Spanish)

* New translations environments-vagrant.md (Spanish)

* New translations cookies.md (Spanish)

* New translations mvc.md (Spanish)

* New translations environments-nanobox.md (Spanish)

* New translations views.md (Spanish)

* New translations tag.md (Spanish)

* New translations acl.md (Spanish)

* New translations logging.md (Filipino)

* New translations installation.md (Filipino)

* New translations acl.md (Spanish)

* New translations db-odm.md (Spanish)

* New translations cache.md (Spanish)

* New translations queue.md (Spanish)

* New translations events.md (Spanish)

* New translations cache.md (Turkish)

* New translations queue.md (Turkish)

* New translations session.md (Spanish)

* New translations webserver-setup.md (Filipino)

* New translations environments-docker.md (Filipino)

* New translations session.md (Filipino)

* New translations image.md (Filipino)

* New translations session.md (Filipino)

* New translations volt.md (Tagalog)

* New translations image.md (Filipino)

* New translations volt.md (Tagalog)

* New translations webserver-xampp.md (Tagalog)

* New translations webserver-wamp.md (Tagalog)

* New translations tutorial-vokuro.md (Filipino)

* New translations url.md (Filipino)

* New translations webserver-setup.md (Tagalog)

* New translations views.md (Tagalog)

* New translations db-pagination.md (Filipino)

* New translations validation.md (Tagalog)

* New translations url.md (Tagalog)

* New translations tutorial-vokuro.md (Tagalog)

* New translations db-models-behaviors.md (Filipino)

* New translations db-models-behaviors.md (Filipino)

* New translations routing.md (Tagalog)

* New translations tutorial-rest.md (Tagalog)

* New translations routing.md (Tagalog)

* New translations tutorial-base.md (Tagalog)

* New translations tutorial-base.md (Filipino)

* New translations tutorial-base.md (Filipino)

* New translations translate.md (Tagalog)

* New translations session.md (Tagalog)

* New translations image.md (Tagalog)

* New translations translate.md (Filipino)

* New translations tutorial-rest.md (Filipino)

* New translations session.md (Tagalog)

* New translations image.md (Tagalog)

* New translations tutorial-rest.md (Filipino)

* New translations tag.md (Tagalog)

* New translations installation.md (Tagalog)

* New translations i18n.md (Tagalog)

* New translations forms.md (Tagalog)

* New translations sidebar.md (Tagalog)
  • Loading branch information...
niden committed Feb 20, 2018
1 parent a0b9dbc commit 2f4c095bcbefd26f443edd25ea0728f7dbe401a2
Showing with 13,096 additions and 0 deletions.
  1. +318 −0 fil/db-models-behaviors.md
  2. +209 −0 fil/db-pagination.md
  3. +342 −0 fil/image.md
  4. +233 −0 fil/session.md
  5. +185 −0 fil/translate.md
  6. +684 −0 fil/tutorial-base.md
  7. +681 −0 fil/tutorial-rest.md
  8. +196 −0 fil/tutorial-vokuro.md
  9. +239 −0 fil/url.md
  10. +701 −0 tl/forms.md
  11. +137 −0 tl/i18n.md
  12. +342 −0 tl/image.md
  13. +568 −0 tl/installation.md
  14. +1,315 −0 tl/routing.md
  15. +233 −0 tl/session.md
  16. +89 −0 tl/sidebar.md
  17. +823 −0 tl/tag.md
  18. +185 −0 tl/translate.md
  19. +682 −0 tl/tutorial-base.md
  20. +679 −0 tl/tutorial-rest.md
  21. +196 −0 tl/tutorial-vokuro.md
  22. +239 −0 tl/url.md
  23. +579 −0 tl/validation.md
  24. +1,191 −0 tl/views.md
  25. +1,564 −0 tl/volt.md
  26. +331 −0 tl/webserver-setup.md
  27. +70 −0 tl/webserver-wamp.md
  28. +85 −0 tl/webserver-xampp.md
@@ -0,0 +1,318 @@
<div class='article-menu'>
<ul>
<li>
<a href="#overview">Mga Pag-uugali ng Modelo</a> <ul>
<li>
<a href="#timestampable">TatakangOras</a>
</li>
<li>
<a href="#softdelete">MalambutangPagtatanggal</a>
</li>
<li>
<a href="#create-your-own-behaviors">Paggawa ng Sariling mong mga Pag-uugali</a>
</li>
<li>
<a href="#traits-as-behaviors">Paggamit ng mga Katangian bilang mga Pag-uugali</a>
</li>
</ul>
</li>
</ul>
</div>

<a name='overview'></a>

# Mga Pag-uugali ng Modelo

Ang mga pag-uugaling ibinabahagi ay naglilitis na iilan sa mga modelo ay maaaring mag-adopt upang magamit muli ang mga code, ang ORM ay nagbibigay ng isang API upang ipatupad ang mga ugali ng iyong mga modelo. At saka, maari mo ring gamitin ang mga kaganapan at ang mga callback na siya ring nakita nung una bilang isang alternatibo upang ipatupad ang mga Pag-uugali nang may higit pang kalayaan.

Ang isang pag-uugali ay dapat idagdag sa nagpapasimulang modelo, ang isang modelo ay maaring magkaroon ng isang zero o higit pang mga ugali:

```php
<?php
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Behavior\Timestampable;
class Users extends Model
{
public $id;
public $name;
public $created_at;
public function initialize()
{
$this->addBehavior(
new Timestampable(
[
'beforeCreate' => [
'field' => 'created_at',
'format' => 'Y-m-d',
]
]
)
);
}
}
```

The following built-in behaviors are provided by the framework:

| Name | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------- |
| Timestampable | Allows to automatically update a model's attribute saving the datetime when a record is created or updated |
| SoftDelete | Instead of permanently delete a record it marks the record as deleted changing the value of a flag column |

<a name='timestampable'></a>

## Timestampable

This behavior receives an array of options, the first level key must be an event name indicating when the column must be assigned:

```php
<?php
use Phalcon\Mvc\Model\Behavior\Timestampable;
public function initialize()
{
$this->addBehavior(
new Timestampable(
[
'beforeCreate' => [
'field' => 'created_at',
'format' => 'Y-m-d',
]
]
)
);
}
```

Each event can have its own options, `field` is the name of the column that must be updated, if `format` is a string it will be used as format of the PHP's function [date](http://php.net/manual/en/function.date.php), format can also be an anonymous function providing you the free to generate any kind timestamp:

```php
<?php
use DateTime;
use DateTimeZone;
use Phalcon\Mvc\Model\Behavior\Timestampable;
public function initialize()
{
$this->addBehavior(
new Timestampable(
[
'beforeCreate' => [
'field' => 'created_at',
'format' => function () {
$datetime = new Datetime(
new DateTimeZone('Europe/Stockholm')
);
return $datetime->format('Y-m-d H:i:sP');
}
]
]
)
);
}
```

If the option `format` is omitted a timestamp using the PHP's function [time](http://php.net/manual/en/function.time.php), will be used.

<a name='softdelete'></a>

## SoftDelete

This behavior can be used as follows:

```php
<?php
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class Users extends Model
{
const DELETED = 'D';
const NOT_DELETED = 'N';
public $id;
public $name;
public $status;
public function initialize()
{
$this->addBehavior(
new SoftDelete(
[
'field' => 'status',
'value' => Users::DELETED,
]
)
);
}
}
```

This behavior accepts two options: `field` and `value`, `field` determines what field must be updated and `value` the value to be deleted. Let's pretend the table `users` has the following data:

```sql
mysql> select * from users;
+----+---------+--------+
| id | name | status |
+----+---------+--------+
| 1 | Lana | N |
| 2 | Brandon | N |
+----+---------+--------+
2 rows in set (0.00 sec)
```

If we delete any of the two records the status will be updated instead of delete the record:

```php
<?php
Users::findFirst(2)->delete();
```

The operation will result in the following data in the table:

```sql
mysql> select * from users;
+----+---------+--------+
| id | name | status |
+----+---------+--------+
| 1 | Lana | N |
| 2 | Brandon | D |
+----+---------+--------+
2 rows in set (0.01 sec)
```

Note that you need to specify the deleted condition in your queries to effectively ignore them as deleted records, this behavior doesn't support that.

<a name='create-your-own-behaviors'></a>

## Creating your own behaviors

The ORM provides an API to create your own behaviors. A behavior must be a class implementing the `Phalcon\Mvc\Model\BehaviorInterface`. Also, `Phalcon\Mvc\Model\Behavior` provides most of the methods needed to ease the implementation of behaviors.

The following behavior is an example, it implements the Blameable behavior which helps identify the user that is performed operations over a model:

```php
<?php
use Phalcon\Mvc\Model\Behavior;
use Phalcon\Mvc\Model\BehaviorInterface;
class Blameable extends Behavior implements BehaviorInterface
{
public function notify($eventType, $model)
{
switch ($eventType) {
case 'afterCreate':
case 'afterDelete':
case 'afterUpdate':
$userName = // ... get the current user from session
// Store in a log the username, event type and primary key
file_put_contents(
'logs/blamable-log.txt',
$userName . ' ' . $eventType . ' ' . $model->id
);
break;
default:
/* ignore the rest of events */
}
}
}
```

The former is a very simple behavior, but it illustrates how to create a behavior, now let's add this behavior to a model:

```php
<?php
use Phalcon\Mvc\Model;
class Profiles extends Model
{
public function initialize()
{
$this->addBehavior(
new Blameable()
);
}
}
```

A behavior is also capable of intercepting missing methods on your models:

```php
<?php
use Phalcon\Tag;
use Phalcon\Mvc\Model\Behavior;
use Phalcon\Mvc\Model\BehaviorInterface;
class Sluggable extends Behavior implements BehaviorInterface
{
public function missingMethod($model, $method, $arguments = [])
{
// If the method is 'getSlug' convert the title
if ($method === 'getSlug') {
return Tag::friendlyTitle($model->title);
}
}
}
```

Call that method on a model that implements Sluggable returns a SEO friendly title:

```php
<?php
$title = $post->getSlug();
```

<a name='traits-as-behaviors'></a>

## Using Traits as behaviors

You can use [Traits](http://php.net/manual/en/language.oop5.traits.php) to re-use code in your classes, this is another way to implement custom behaviors. The following trait implements a simple version of the Timestampable behavior:

```php
<?php
trait MyTimestampable
{
public function beforeCreate()
{
$this->created_at = date('r');
}
public function beforeUpdate()
{
$this->updated_at = date('r');
}
}
```

Then you can use it in your model as follows:

```php
<?php
use Phalcon\Mvc\Model;
class Products extends Model
{
use MyTimestampable;
}
```
Oops, something went wrong.

0 comments on commit 2f4c095

Please sign in to comment.