Skip to content

Instantly share code, notes, and snippets.

@nervetattoo
Last active December 15, 2015 23:19
Show Gist options
  • Save nervetattoo/5339494 to your computer and use it in GitHub Desktop.
Save nervetattoo/5339494 to your computer and use it in GitHub Desktop.
Lithium code examples
<?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;
});
<?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()
);
}
}
<?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