Last active
December 15, 2015 23:19
-
-
Save nervetattoo/5339494 to your computer and use it in GitHub Desktop.
Lithium code examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Model::applyFilter('save', function($self, $params, $chain) { | |
$params['entity']->modified = time(); | |
$result = $chain->next($self, $params, $chain); | |
// This will happen after a succesfull save | |
if ($result) { | |
ExternalSync::syncObject($params['entity']); | |
} | |
return $result; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use app\models\Model; | |
class FooController extends lithium\action\Controller { | |
/** | |
* Will render the views/foo/bar.html.php view by default | |
*/ | |
public function bar() { | |
return array( | |
'results' => Model::all() | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Model::find($type, array $options); | |
Model::save($entity, $data, array $options); | |
Collection::map($callback, array $options); | |
Media::type($type, $content, array $options); | |
Router::connect($template, $params, array $options); | |
Controller::redirect($url, array $options); | |
Auth::set($name, $data, array $options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment