# |
Jun 27th 2019, 08:35 |
admad |
Any event you dispatch will be sent to global instance too |
# |
Jun 27th 2019, 08:32 |
madbbb |
why can't shell use global instance? |
# |
Jun 27th 2019, 08:31 |
admad |
Yes, you are setting on global instance |
# |
Jun 27th 2019, 08:29 |
madbbb |
$this->getEventManager() is clean without any listeners on it. Are instances are different? |
# |
Jun 27th 2019, 08:22 |
madbbb |
bootstrap.php loads after bootstrap_cli.php |
# |
Jun 27th 2019, 08:17 |
kgb.acct.personal |
bootstrap_cli.php |
# |
Jun 27th 2019, 08:11 |
madbbb |
I register my event listeners in bootstrap.php file everything work as expected, but I can't see registered listeners in my shell. Where do I register them to get listeners work in shell? |
# |
Jun 27th 2019, 08:06 |
madbbb |
Morning! |
# |
Jun 27th 2019, 07:45 |
conehead |
Hmm if you would want the user to let him choose which fields he wants to be seen in a form and which not. How would you go for it? Save his configuration in the database and pass it into each session. When rendering the form access the session and check if the field should be visible? |
# |
Jun 27th 2019, 07:31 |
neon1024 |
Morning everyone |
# |
Jun 27th 2019, 07:19 |
conehead |
Is the expected value in code_id? Or is the value incorrect? |
# |
Jun 27th 2019, 05:29 |
slackebot |
else { $this->log('no save'); } } } ``` |
# |
Jun 27th 2019, 05:29 |
chan |
after save data i want to save code_id by auto increment id, but code_id not save in table, what wrong? my coding is following. i write model of cakephp2 afterSave function. ``` public function afterSave($created, $options = array()) { if ($created) { $this->data[$this->alias]['id'] = $this->id; $this->data[$this->alias]['code_id'] = 'U' . str_pad($this->id, 5, "0", STR_PAD_LEFT); if($this->save($this->data)) { $this->log('save'); } |
# |
Jun 27th 2019, 03:00 |
challgren |
CakePHP 3.8.0 is released!! https://github.com/cakephp/cakephp/releases/tag/3.8.0 |
# |
Jun 26th 2019, 22:42 |
mdotobie |
Makes sense @cnizzardini. Sounds like you can still throw some exceptions from your abstraction for a nicer developer experience though |
# |
Jun 26th 2019, 22:34 |
cnizzardini |
But if an engineer goes to use it wrong, it should fail fantastically anyways, even without a nice LogicException message |
# |
Jun 26th 2019, 22:33 |
cnizzardini |
@mdotobie my use case is different than that, pulling data from db and passing it into an absraction layer, would've been nice if was easy |
# |
Jun 26th 2019, 22:24 |
mdotobie |
I’ll use `debug()` on the `$form` object in the console and see if the output matches |
# |
Jun 26th 2019, 22:20 |
mdotobie |
That’s a good point. I’m not using `__dumpinfo()` directly but that output happens in the console right after the object is instantiated so Psy might be using it for output it and i just don’t realize it |
# |
Jun 26th 2019, 22:18 |
ndm |
@mdotobie Are you maybe dumping the form object? Like `debug($form)`? In that case it would be invoked from `Form::__debugInfo()`, but other than that, it shouldn't. Set a breakpoint or dump a stacktrace (`debug(\Cake\Error\Debugger::trace())`) to get more info about from where it's being called. |
# |
Jun 26th 2019, 22:14 |
slackebot |
the Table level anyway. |
# |
Jun 26th 2019, 22:14 |
mdotobie |
@cnizzardini if you are getting all your Person entity objects as the result of a query you can pretty much guarantee the ResultsSet will be all Person objects. If you’re building the entities from data you get from a form for instance then yes, you could technically create an array that had Person entities intermixed with entities of other types, but I’m not sure what you’d do with it. Attempting to save that array of entities would f |
# |
Jun 26th 2019, 22:11 |
mdotobie |
I thought that @ndm but when I use the console and do something like `$form = new App\Form\ApprovalForm` I can see the fields populated from the `buildSchema` method. It seems to suggest that it’s building the schema before I ever get to the FormHelper |
# |
Jun 26th 2019, 22:10 |
cnizzardini |
prob not, i am likely being too anal about exact arguments anyways |
# |
Jun 26th 2019, 22:09 |
ndm |
@mdtobe The form itself doesn't call it, it's called in various methods in the`\Cake\View\Form\Context\FormContext` class. |
# |
Jun 26th 2019, 22:09 |
mdotobie |
Are you creating the Person entities from some external data? |
# |
Jun 26th 2019, 22:08 |
mdotobie |
I assume you’d be getting the entities from a database query tho |
# |
Jun 26th 2019, 22:08 |
mdotobie |
That would be a `ResultsSet` |
# |
Jun 26th 2019, 22:08 |
cnizzardini |
And if its not an instance of that it throws a LogicException |
# |
Jun 26th 2019, 22:07 |
cnizzardini |
would be nice if I could define something as a collection of App\Model\Enity\Person |
# |
Jun 26th 2019, 22:06 |
cnizzardini |
not really |
# |
Jun 26th 2019, 22:04 |
mdotobie |
I’m thinking that’s what you’re going for @cnizzardini |
# |
Jun 26th 2019, 22:00 |
mdotobie |
if it encounters an object that doesn’t belong to that class in the array it will return false and fail |
# |
Jun 26th 2019, 21:58 |
mdotobie |
and then do something like `$isObjectCollection = $collection->every(function ($object) { return $object instanceof someClass; }); |
# |
Jun 26th 2019, 21:57 |
mdotobie |
You could then say `$collection = new Cake\Collection\Collection($objects); |
# |
Jun 26th 2019, 21:56 |
slackebot |
<mdotobie> |
# |
Jun 26th 2019, 21:54 |
mdotobie |
so lets say you had something like: |
# |
Jun 26th 2019, 21:53 |
mdotobie |
well you’d write a closure for something like Collection::every() |
# |
Jun 26th 2019, 21:53 |
cnizzardini |
like does it complain if I chuck in something goofy? |
# |
Jun 26th 2019, 21:52 |
mdotobie |
You’d need to make the base array into a collection first |
# |
Jun 26th 2019, 21:52 |
cnizzardini |
Does that just happen magically |