2015年5月22日星期五

NetTuts.com: Programming With Yii2: Timestamp Behavior


NetTuts.com has posted the next part of their "Programming with Yii2" tutorial series today. This new tutorial in the series focuses on the use of the timestamp behavior to assign the current date to an object (like for create or update dates).



In this tutorial, we'll explore Timestamp Behaviors, which reduce the amount of code you need to write with each new model for the common operation of creating timestamps for inserts and updates. We'll also dive into the Yii2 source code, examining how a behavior is implemented.


He starts with a brief look at what behaviors are (a reminder for those that may have already read about the sluggable and blameable behaviors). He then gets into the Timestamp behavior specifically and how to apply it to the sample project's "Status" instances. He shows the updates needed for the behavior configuration and rules. He also looks inside the component at the code that makes it up and the "touch" method it provides.


Link: http://code.tutsplus.com/tutorials/programming-with-yii2-timestamp-behavior--cms-23329

没有评论:

发表评论