Log message #4223093

# At Username Text
# Jan 20th, 15:36 neon1024 You’d also want to do it for matching
# Jan 20th, 15:33 neon1024 …and doesn’t match the framework documentation and the code is often hidden and not obvious, making the behaviour hard to understand, unless you “just know it”
# Jan 20th, 15:32 neon1024 Although I’m not a fan of changes like this because it’s often undocumented and produces behaviour which isn’t consistent with the framework
# Jan 20th, 15:31 neon1024 That controls the conversion
# Jan 20th, 15:29 neon1024 I’d look at `_hydrate()` method in Query
# Jan 20th, 15:24 val @ndm, @admad what method should be overriden if I want that `Cake\ORM\Query->first()` would return a special object instead of `null` in case when no record is found in 3.x? I have difficulties in locating places where the entities are actually constructed.
# Jan 20th, 14:23 ricksaccous @admad nice if that's the case that might make things loads easier, i'm going to try that
# Jan 20th, 14:07 martin https://www.munderwood.ca/index.php/2017/02/28/responding-to-http-options-requests-in-cakephp/ this way
# Jan 20th, 14:07 martin fixed the options method with a middleware :)
# Jan 20th, 13:36 admad you can instead just use `$file->getStream()->getMetadata()['uri']` to get the file path to pass to flysystem
# Jan 20th, 13:35 ndm or reattach it
# Jan 20th, 13:35 admad so be sure you don't need to use the stream instance afterwards :)
# Jan 20th, 13:34 admad "After the stream has been detached, the stream is in an unusable state."
# Jan 20th, 13:33 ndm np
# Jan 20th, 13:33 ricksaccous Thanks
# Jan 20th, 13:32 ndm so `$upload->getStream()->detach()`
# Jan 20th, 13:32 ricksaccous Alright awesome I'll try detach
# Jan 20th, 13:32 ndm detach() will give you the resource ig neccesary
# Jan 20th, 13:32 mr.kusmadi @ricksaccous Use this $datas = $this->request->getData(); $datas['logo']->getClientMediaType(); //to check type of file $datas['logo']->getClientFilename(); //to get filename
# Jan 20th, 13:32 admad it's sad the flysystem doesn't directly support psr7 stream objects
# Jan 20th, 13:31 ricksaccous Or whatever that library is
# Jan 20th, 13:31 ricksaccous To feed it to FlySystem Adapters lol
# Jan 20th, 13:31 ndm Why would you want to do that?
# Jan 20th, 13:30 ricksaccous So how do I turn it into a resource after calling getStream()?
# Jan 20th, 13:29 ndm And a class that calls itself stream isn't a resource, but it usually holds a resource
# Jan 20th, 13:28 ndm @ricksaccous All streams are resources, but not all resources are streams. To obtain the stream of an uploaded file object, use its `getStream()` method.
# Jan 20th, 13:26 HumanG33k and the wrong json
# Jan 20th, 13:26 HumanG33k @chalgren ok thx the only thing missing at the end was the application.php stuff
# Jan 20th, 13:25 martin Hi, I'm currently rebuild a project (with CRUD plugin) to REST backend, but I see that the OPTIONS http method always returns 404. what is a good way to fix this? the frontent does a OPTIONS method before delete/put to check the CORS
# Jan 20th, 13:25 ricksaccous How do you translate that object you get into a resource
# Jan 20th, 13:24 ricksaccous In CakePHP4 it seems that for file uploads you get that object but the file property is private that I'm used to using
# Jan 20th, 13:23 ricksaccous I'm having trouble wrapping my head around the difference between streams and resources and consequently getting a resource from a stream
# Jan 20th, 13:20 slackebot Alhamdulillah successfully
# Jan 20th, 13:20 slackebot $authenticationService->loadAuthenticator('Authentication.Form', [ 'resolver' => [ 'className' => 'Authentication.AdminOrm', 'userModels' => ['Admin','Users','Students'], ], 'fields' => [ 'username' => 'username', 'password' => 'password', ], 'loginUrl' => ['/simsiswa/admin','/simsiswa/staff','/simsiswa/user'], ]);``` #6.
# Jan 20th, 13:20 slackebot 'userModels' => ['Admin','Users','Students'], ], 'fields' => [ 'username' => 'username', 'password' => 'password', ], ]); // Load the authenticators, you want session first $authenticationService->loadAuthenticator('Authentication.Session'); // Configure form data check to pick username and password
# Jan 20th, 13:20 slackebot if (is_string($options)) { $query->find($options); } else { $query->find($finder, $options); } } $where = []; foreach ($conditions as $field => $value) { $field = $table->aliasField($field); if (is_array($value)) { $field = $field . ' IN'; }
# Jan 20th, 13:20 slackebot $where[$field] = $value; } if($query->where([$type => $where])->first() != null){ return $query->where([$type => $where])->first(); } } }``` #5. Open src/Application.php #6. Modify this code ``` $authenticationService->loadIdentifier('Authentication.Password', [ 'resolver' => [ 'className' => 'Authentication.AdminOrm',
# Jan 20th, 13:20 slackebot 'userModels' => [], 'finder' => 'all', ];``` #4. Modify this code ``` public function find(array $conditions, $type = self::TYPE_AND) { foreach($this->_config['userModels'] as $configUserModels){ $table = $this->getTableLocator()->get($configUserModels); $query = $table->query(); $finders = (array)$this->_config['finder']; foreach ($finders as $finder => $options) {
# Jan 20th, 13:20 mr.kusmadi Hai @ricksaccous @conehead I am glad, your suggestion was successful *Hope it is useful for others* *How do you create multiple logins with multiple tables on cakephp 4.x?* #1. I have followed the guidelines at https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html #2. Open app/vendor/cakephp/authentication/src/Identifier/Resolver/OrmResolver.php #3. Modify this code ``` protected $_defaultConfig = [
# Jan 20th, 12:33 barlas So, remove the plugins, install cake 4, and then re-add them if required.
# Jan 20th, 12:32 neon1024 You’ll need to use the cake 4 compatible versions of the plugins, or remove ones which do not yet support cake 4