-
Notifications
You must be signed in to change notification settings - Fork 10
Factory
Devin Smith edited this page Feb 3, 2016
·
2 revisions
Factory provides an in memory cache of objects with a type, key, value store system. This is enabled by default for Resource.
When objects are loaded from the database using the load method they are automatically added to the factory cache.
$user = User::o(1);
$user->name = 'new name';
$user = User::o(1); // load the item from memory instead of another database call
echo $user->name; // prints "new name"
The factory method gets or sets an object by classname, or passed object
$object = new User([
id => 1
]);
$u = $tipsy->factory($object);
// or
$u = $tipsy->factory('User', $object);
Disable in php
$tipsy->config(['tipsy' => ['factory' => false]]);
or in a config file
tipsy:
factory: false
- Home
- Getting Started
- Server Config
- Installation
- Installing Composer
- App
- Route Shorthand
- Config
- Routes
- Methods
- Controller Types
- Params & Regex
- Aliases
- Dependency Injection
- Advanced Routing
- Services
- User Defined Services
- Built in Services
- Middleware
- Views
- Templates
- Scope
- Resource
- Factory
- Looper
- Examples
- Plugins
- About