Tuesday, January 13, 2015

3.0 - Inflections

My friends, i try to customize my inflections for cake 3.0 rc1.

When i used cake 2.0 i used this:


// Plural to singular
Inflector::rules('singular', [
    'rules' => [
        '/^(.*)(oes|aes|aos)$/i' => '\1ao',
    ],
    'irregular' => [
        'panels' => 'panel',
        'Requests' => 'Requests',
    ],
    'uninflected' => []
]);

// Singular to plural
Inflector::rules('plural', [
    'rules' => [
        '/^(.*)ao$/i' => '\1oes',
    ],
    'irregular' => [
        'panel' => 'panels',
    ],
    'uninflected' => []
]); 


In cake 3.0 i received this error.


Trace error

Warning (2): preg_match(): Delimiter must not be alphanumeric or backslash [CORE/src/Utility/Inflector.php, line 569]
Code Context
$word = 'Requests'  $regs = []  $rule = 'rules'  $replacement = [  	'/^(.*)(oes|aes|aos)$/i' => '\1ao'  ]
preg_match - [internal], line ??  Cake\Utility\Inflector::singularize() - CORE/src/Utility/Inflector.php, line 569  Cake\ORM\Table::entityClass() - CORE/src/ORM/Table.php, line 493  Cake\ORM\Marshaller::one() - CORE/src/ORM/Marshaller.php, line 108  Cake\ORM\Table::newEntity() - CORE/src/ORM/Table.php, line 1829  DebugKit\Routing\Filter\DebugBarFilter::afterDispatch() - ROOT/plugins/DebugKit/src/Routing/Filter/DebugBarFilter.php, line 187  Cake\Event\EventManager::_callListener() - CORE/src/Event/EventManager.php, line 276  Cake\Event\EventManager::dispatch() - CORE/src/Event/EventManager.php, line 242  Cake\Routing\Dispatcher::dispatchEvent() - CORE/src/Event/EventManagerTrait.php, line 78  Cake\Routing\Dispatcher::dispatch() - CORE/src/Routing/Dispatcher.php, line 92  [main] - ROOT/webroot/index.php, line 37

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: