Re: cake 3 - issue saving null datetime

2014-04-29 Thread Alberto Pagliarini
yep :)


2014-04-29 0:07 GMT+02:00 euromark :

> See - already fixed after not even 1 hour :)
>
> Am Montag, 28. April 2014 22:35:02 UTC+2 schrieb bato:
>
>> I opened an issue https://github.com/cakephp/cakephp/issues/3410
>>
>> Il giorno lunedì 28 aprile 2014 18:46:28 UTC+2, euromark ha scritto:
>>>
>>> Sounds like the case here.
>>> You maybe should open a github issue regarding this.
>>>
>>> Am Montag, 28. April 2014 10:15:44 UTC+2 schrieb bato:

 Hi all,

 I have a table with a field 'date_start' that can be nullable. I have a
 fatal error when try to save null value on db.
 In my controller I have:

 $data['start_date'] = null;
 $c = TableRegistry::get('Contents');
 $e = $c->newEntity($data);
 $c->save($e);

 and the fatal error is

 Error: Call to a member function format() on a non-object
 File //vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php
 Line: 62

 I think there is a bug because the  Cake\Database\Type\
 DateTimeType::toDatabase($value, Driver $driver) method doesn't check
 if $value is null and try to use a method on it $value->format($this->_
 format);

 Is it a bug?

 alberto

>>>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/TU6D6QnnFKI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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.
>



-- 
-- bato ---

-- 
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+unsubscr...@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.


Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
OK, I've got it. I will have a look to compile() method.
Thanks for your help
Il 16/apr/2014 21:06 "José Lorenzo"  ha scritto:

> Yeah, it will execute it as many times as you iterate the results. If you
> want to "cache" the results of a set of formatters call "compile()" on the
> resulting collection. This is because it needs to make sure formatters are
> applied to all rows.
>
>
> On Wednesday, April 16, 2014 5:06:38 PM UTC+2, bato wrote:
>>
>> uhm... I found when it repeats twice.
>>
>> try
>>
>> $table = TableRegistry::get('Articles');
>> $table
>>  ->find()
>> ->formatResults(function($r) {
>> return $r->map(function($r) {
>>  debug('a');
>> return $r;
>> });
>>  })
>> ->first();
>>
>> debug($table->toArray());
>>
>> I have debug($table->toArray()); after the find chain. I suppose that
>> first() already execute the query. Is it right?
>> But when I do toArray() it shouldn't redo the formatResults operation,
>> right?
>>
>>
>> 2014-04-16 14:45 GMT+02:00 José Lorenzo :
>>
>>> I just tested with this code and checked that the callback is executed
>>> only once:
>>>
>>>  $table = TableRegistry::get('Articles');
>>> $table
>>> ->find()
>>>  ->formatResults(function($r) {
>>> return $r->map(function($r) {
>>> debug('a');
>>>  return $r;
>>> });
>>> })
>>> ->first();
>>>
>>> On Wednesday, April 16, 2014 2:33:35 PM UTC+2, José Lorenzo wrote:

 Paste the full code where you see it being called twice, please. I will
 also check with my own code

 On Wednesday, April 16, 2014 2:23:54 PM UTC+2, bato wrote:
>
> ok it works!
>
> To me remain a mistery why using first() the callback in
> $results->map() is called twice while not using first is called once.
>
> Could it be a bug?
>
>
> 2014-04-16 13:11 GMT+02:00 José Lorenzo :
>
>> Try this
>>
>> public findFlat($query, $options = []) {
>> return $query->formatResults(function($results, $query) {
>>  return $results->map(function($row) {
>> if ($row->content) {
>> $row->set($row->content->toArray(), ['guard' => false]);
>>  $row->unsetProperty('content');
>> }
>> return $row;
>>  });
>> });
>> }
>>
>> $row = $table->find('flat')->first();
>>
>>
>> On Tuesday, April 15, 2014 10:04:25 AM UTC+2, bato wrote:
>>>
>>> uhm...
>>>
>>> maybe I'm wrong to use map() function...
>>>
>>> return $results->map(function($row) {
>>> foreach ($row['content']->toArray() as $key =>
>>> $value) {
>>> $row[$key] = $value;
>>> }
>>> unset($row['content']);
>>> return $row;
>>> });
>>>
>>>
>>> In my db I have only one row.
>>> When I find all results the callback inside map() is called one
>>> time.
>>> If I add first() to chain then it's called two times and the second
>>> time $row['content'] is undefined because I unset it before so thrown 
>>> fatal
>>> error. Why is it called two times?
>>>
>>> Suggestions?
>>>
>>>
>>> 2014-04-15 9:22 GMT+02:00 bato :
>>>
 Sure,

 I'm trying to add 'content' properties to main Entity properties
 (it's an exercise to collpase entities properties in an array)

 [
 (int) 0 => object(App\Model\Entity\Object) {

 'new' => false,
 'accessible' => [
  '*' => true
 ],
  'properties' => [
 'id' => (int) 5,
  'object_type_id' => (int) 12,
 'status' => 'on',
  'created' => object(DateTime) {
 date => '2014-03-07 09:21:29'
  timezone_type => (int) 3
 timezone => 'Europe/Rome'
  },
 'modified' => object(DateTime) {
  date => '2014-04-07 23:32:48'
 timezone_type => (int) 3
  timezone => 'Europe/Rome'
 },
  'start_date' => null,
 'end_date' => null,
  'subject' => null,
 'abstract' => null,
  'body' => null,
 'duration' => null
  ],
 'dirty' => [
  'id' => true,
 'start_date' => true,
  'end_date' => true,
 'subject' => true,
  'abstract' => true,
 'body' => true,
  'duration' => true
 ],
  'virtual' => [],
 'errors' => [],
  'repository' => 'ImageObjects'
  }
 ]

 This is the results of find all. In 'dirty' key you can see the
 'content' properties that I add to App\Model\Entity\Object properties.
 I unset the 'content' key so it isn't show in the above array.

 I'm playing with ORM feature and I would want to know if
 formatResults is usable in query chain.


 Il giorno lunedì 14 aprile 2014 11:40:53 UTC+2, José Lorenzo ha
 scritto:
>
> Can you explain wh

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
uhm... I found when it repeats twice.

try

$table = TableRegistry::get('Articles');
$table
->find()
->formatResults(function($r) {
return $r->map(function($r) {
debug('a');
return $r;
});
})
->first();

debug($table->toArray());

I have debug($table->toArray()); after the find chain. I suppose that
first() already execute the query. Is it right?
But when I do toArray() it shouldn't redo the formatResults operation,
right?


2014-04-16 14:45 GMT+02:00 José Lorenzo :

> I just tested with this code and checked that the callback is executed
> only once:
>
> $table = TableRegistry::get('Articles');
> $table
> ->find()
> ->formatResults(function($r) {
> return $r->map(function($r) {
> debug('a');
> return $r;
> });
> })
> ->first();
>
> On Wednesday, April 16, 2014 2:33:35 PM UTC+2, José Lorenzo wrote:
>>
>> Paste the full code where you see it being called twice, please. I will
>> also check with my own code
>>
>> On Wednesday, April 16, 2014 2:23:54 PM UTC+2, bato wrote:
>>>
>>> ok it works!
>>>
>>> To me remain a mistery why using first() the callback in $results->map()
>>> is called twice while not using first is called once.
>>>
>>> Could it be a bug?
>>>
>>>
>>> 2014-04-16 13:11 GMT+02:00 José Lorenzo :
>>>
 Try this

 public findFlat($query, $options = []) {
 return $query->formatResults(function($results, $query) {
  return $results->map(function($row) {
 if ($row->content) {
 $row->set($row->content->toArray(), ['guard' => false]);
  $row->unsetProperty('content');
 }
 return $row;
  });
 });
 }

 $row = $table->find('flat')->first();


 On Tuesday, April 15, 2014 10:04:25 AM UTC+2, bato wrote:
>
> uhm...
>
> maybe I'm wrong to use map() function...
>
> return $results->map(function($row) {
> foreach ($row['content']->toArray() as $key => $value)
> {
> $row[$key] = $value;
> }
> unset($row['content']);
> return $row;
> });
>
>
> In my db I have only one row.
> When I find all results the callback inside map() is called one time.
> If I add first() to chain then it's called two times and the second
> time $row['content'] is undefined because I unset it before so thrown 
> fatal
> error. Why is it called two times?
>
> Suggestions?
>
>
> 2014-04-15 9:22 GMT+02:00 bato :
>
>> Sure,
>>
>> I'm trying to add 'content' properties to main Entity properties
>> (it's an exercise to collpase entities properties in an array)
>>
>> [
>> (int) 0 => object(App\Model\Entity\Object) {
>>
>> 'new' => false,
>> 'accessible' => [
>>  '*' => true
>> ],
>>  'properties' => [
>> 'id' => (int) 5,
>>  'object_type_id' => (int) 12,
>> 'status' => 'on',
>>  'created' => object(DateTime) {
>> date => '2014-03-07 09:21:29'
>>  timezone_type => (int) 3
>> timezone => 'Europe/Rome'
>>  },
>> 'modified' => object(DateTime) {
>>  date => '2014-04-07 23:32:48'
>> timezone_type => (int) 3
>>  timezone => 'Europe/Rome'
>> },
>>  'start_date' => null,
>> 'end_date' => null,
>>  'subject' => null,
>> 'abstract' => null,
>>  'body' => null,
>> 'duration' => null
>>  ],
>> 'dirty' => [
>>  'id' => true,
>> 'start_date' => true,
>>  'end_date' => true,
>> 'subject' => true,
>>  'abstract' => true,
>> 'body' => true,
>>  'duration' => true
>> ],
>>  'virtual' => [],
>> 'errors' => [],
>>  'repository' => 'ImageObjects'
>>  }
>> ]
>>
>> This is the results of find all. In 'dirty' key you can see the
>> 'content' properties that I add to App\Model\Entity\Object properties.
>> I unset the 'content' key so it isn't show in the above array.
>>
>> I'm playing with ORM feature and I would want to know if
>> formatResults is usable in query chain.
>>
>>
>> Il giorno lunedì 14 aprile 2014 11:40:53 UTC+2, José Lorenzo ha
>> scritto:
>>>
>>> Can you explain what you are trying to do? I'm not sure I get it
>>> from your code example.
>>>
>>> On Monday, April 14, 2014 11:31:42 AM UTC+2, bato wrote:

 Hi,

 I'm trying to figure out if it's possible to use formatResults in
 custom finder methods to use ORM chain. I have seen in docs the example
 with mapper reducer.

 In my table object i have

 public findFlat($query, $options = []) {
return $query->formatResults(function($results, $query) {
 return $results->map(function($row) {
 foreach ($row['content']->toArray() as $key =>
 $value) {
 $row[$key] = $value;
 }
 unset

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
ok it works!

To me remain a mistery why using first() the callback in $results->map() is
called twice while not using first is called once.

Could it be a bug?


2014-04-16 13:11 GMT+02:00 José Lorenzo :

> Try this
>
> public findFlat($query, $options = []) {
> return $query->formatResults(function($results, $query) {
> return $results->map(function($row) {
> if ($row->content) {
> $row->set($row->content->toArray(), ['guard' => false]);
> $row->unsetProperty('content');
> }
> return $row;
> });
> });
> }
>
> $row = $table->find('flat')->first();
>
>
> On Tuesday, April 15, 2014 10:04:25 AM UTC+2, bato wrote:
>>
>> uhm...
>>
>> maybe I'm wrong to use map() function...
>>
>> return $results->map(function($row) {
>> foreach ($row['content']->toArray() as $key => $value) {
>> $row[$key] = $value;
>> }
>> unset($row['content']);
>> return $row;
>> });
>>
>>
>> In my db I have only one row.
>> When I find all results the callback inside map() is called one time.
>> If I add first() to chain then it's called two times and the second time
>> $row['content'] is undefined because I unset it before so thrown fatal
>> error. Why is it called two times?
>>
>> Suggestions?
>>
>>
>> 2014-04-15 9:22 GMT+02:00 bato :
>>
>>> Sure,
>>>
>>> I'm trying to add 'content' properties to main Entity properties (it's
>>> an exercise to collpase entities properties in an array)
>>>
>>> [
>>> (int) 0 => object(App\Model\Entity\Object) {
>>>
>>> 'new' => false,
>>> 'accessible' => [
>>>  '*' => true
>>> ],
>>>  'properties' => [
>>> 'id' => (int) 5,
>>>  'object_type_id' => (int) 12,
>>> 'status' => 'on',
>>>  'created' => object(DateTime) {
>>> date => '2014-03-07 09:21:29'
>>>  timezone_type => (int) 3
>>> timezone => 'Europe/Rome'
>>>  },
>>> 'modified' => object(DateTime) {
>>>  date => '2014-04-07 23:32:48'
>>> timezone_type => (int) 3
>>>  timezone => 'Europe/Rome'
>>> },
>>>  'start_date' => null,
>>> 'end_date' => null,
>>>  'subject' => null,
>>> 'abstract' => null,
>>>  'body' => null,
>>> 'duration' => null
>>>  ],
>>> 'dirty' => [
>>>  'id' => true,
>>> 'start_date' => true,
>>>  'end_date' => true,
>>> 'subject' => true,
>>>  'abstract' => true,
>>> 'body' => true,
>>>  'duration' => true
>>> ],
>>>  'virtual' => [],
>>> 'errors' => [],
>>>  'repository' => 'ImageObjects'
>>>  }
>>> ]
>>>
>>> This is the results of find all. In 'dirty' key you can see the
>>> 'content' properties that I add to App\Model\Entity\Object properties.
>>> I unset the 'content' key so it isn't show in the above array.
>>>
>>> I'm playing with ORM feature and I would want to know if formatResults
>>> is usable in query chain.
>>>
>>>
>>> Il giorno lunedì 14 aprile 2014 11:40:53 UTC+2, José Lorenzo ha scritto:

 Can you explain what you are trying to do? I'm not sure I get it from
 your code example.

 On Monday, April 14, 2014 11:31:42 AM UTC+2, bato wrote:
>
> Hi,
>
> I'm trying to figure out if it's possible to use formatResults in
> custom finder methods to use ORM chain. I have seen in docs the example
> with mapper reducer.
>
> In my table object i have
>
> public findFlat($query, $options = []) {
>return $query->formatResults(function($results, $query) {
> return $results->map(function($row) {
> foreach ($row['content']->toArray() as $key => $value)
> {
> $row[$key] = $value;
> }
> unset($row['content']);
> return $row;
> });
> });
> }
>
> then in my controller I have
>
> $images = TableRegistry::get('ImageObjects');
> $result = $images->find('flat');
> $result->contain(['Contents', 'Streams']);
> debug($result->toArray());
>
> In this way it works but if I add first()
>
> $result->first();
>
> then I obtain a fatal error in findFlat() method
>
> Error: Call to a member function toArray() on a non-object
>
> Any help?
> Am I using wrong formatResults()? Is it possible to chain only mapper
> reducer?
>
> thanks
> alberto
>
>  --
>>> 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 a topic in the
>>> Google Groups "CakePHP" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/cake-php/djk1Ip6_Ca4/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> cake-php+unsubscr...@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.
>>>
>>
>>
>>
>> --
>> -- bato ---
>>
>  --
> Lik

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-15 Thread Alberto Pagliarini
uhm...

maybe I'm wrong to use map() function...

return $results->map(function($row) {
foreach ($row['content']->toArray() as $key => $value) {
$row[$key] = $value;
}
unset($row['content']);
return $row;
});


In my db I have only one row.
When I find all results the callback inside map() is called one time.
If I add first() to chain then it's called two times and the second time
$row['content'] is undefined because I unset it before so thrown fatal
error. Why is it called two times?

Suggestions?


2014-04-15 9:22 GMT+02:00 bato :

> Sure,
>
> I'm trying to add 'content' properties to main Entity properties (it's an
> exercise to collpase entities properties in an array)
>
> [
> (int) 0 => object(App\Model\Entity\Object) {
>
> 'new' => false,
> 'accessible' => [
> '*' => true
> ],
> 'properties' => [
> 'id' => (int) 5,
> 'object_type_id' => (int) 12,
> 'status' => 'on',
> 'created' => object(DateTime) {
> date => '2014-03-07 09:21:29'
> timezone_type => (int) 3
> timezone => 'Europe/Rome'
> },
> 'modified' => object(DateTime) {
> date => '2014-04-07 23:32:48'
> timezone_type => (int) 3
> timezone => 'Europe/Rome'
> },
> 'start_date' => null,
> 'end_date' => null,
> 'subject' => null,
> 'abstract' => null,
> 'body' => null,
> 'duration' => null
> ],
> 'dirty' => [
> 'id' => true,
> 'start_date' => true,
> 'end_date' => true,
> 'subject' => true,
> 'abstract' => true,
> 'body' => true,
> 'duration' => true
> ],
> 'virtual' => [],
> 'errors' => [],
> 'repository' => 'ImageObjects'
>  }
> ]
>
> This is the results of find all. In 'dirty' key you can see the 'content'
> properties that I add to App\Model\Entity\Object properties.
> I unset the 'content' key so it isn't show in the above array.
>
> I'm playing with ORM feature and I would want to know if formatResults is
> usable in query chain.
>
>
> Il giorno lunedì 14 aprile 2014 11:40:53 UTC+2, José Lorenzo ha scritto:
>>
>> Can you explain what you are trying to do? I'm not sure I get it from
>> your code example.
>>
>> On Monday, April 14, 2014 11:31:42 AM UTC+2, bato wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to figure out if it's possible to use formatResults in custom
>>> finder methods to use ORM chain. I have seen in docs the example with
>>> mapper reducer.
>>>
>>> In my table object i have
>>>
>>> public findFlat($query, $options = []) {
>>>return $query->formatResults(function($results, $query) {
>>> return $results->map(function($row) {
>>> foreach ($row['content']->toArray() as $key => $value) {
>>> $row[$key] = $value;
>>> }
>>> unset($row['content']);
>>> return $row;
>>> });
>>> });
>>> }
>>>
>>> then in my controller I have
>>>
>>> $images = TableRegistry::get('ImageObjects');
>>> $result = $images->find('flat');
>>> $result->contain(['Contents', 'Streams']);
>>> debug($result->toArray());
>>>
>>> In this way it works but if I add first()
>>>
>>> $result->first();
>>>
>>> then I obtain a fatal error in findFlat() method
>>>
>>> Error: Call to a member function toArray() on a non-object
>>>
>>> Any help?
>>> Am I using wrong formatResults()? Is it possible to chain only mapper
>>> reducer?
>>>
>>> thanks
>>> alberto
>>>
>>>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/djk1Ip6_Ca4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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.
>



-- 
-- bato ---

-- 
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+unsubscr...@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.


Re: cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

2014-03-30 Thread Alberto Pagliarini
I think you are right about http comunications and probably we will
introduce also a complete backend API rest to use backend data with every
type of frontend app (not only cake app).
But having the possibility to use directly backend core in your frontend
app is more flexible and you don't lose time on http requests improving the
frontend performance.

However maybe another approch could be use the same namespace for frontend
and backend app and in frontend app add to autoloader cake core and some
exposed backend directories (for example App/Model dir). In this way maybe
it doesn't need to explicit the class name. But I have to test it and I
have to think if it's a good idea.

alberto


2014-03-29 12:20 GMT+01:00 mark_story :

> What kinds of things are you thinking woud mak these kinds of situations
> easier? Plugins get you most of the way but I am guessing there are unmet
> requirements/expectations.
>
> You mention you have two separate applications. Have you considered making
> two applications that communicate over http? Separate webservices are used
> in larger organisations with great results.
>
> -mark
>
> --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/MHdseZKF4ts/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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.
>



-- 
-- bato ---

-- 
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+unsubscr...@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.


Re: cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

2014-03-27 Thread Alberto Pagliarini
Well,

I think you're right, for classic simple frontend/backend app (one frontend
with one backend).
But what about have two completely different frontends with different urls?

Our backend handle multiple sites data and can share content between them.
Every frontend is a completely separate project and it uses backend api to
get its data.


2014-03-27 11:50 GMT+01:00 euromark :

> Trust me, you will do yourself and everyone using your app a favor if you
> don't separate the frontend and backend into two apps.
> Most of us would just use plugins and/or admin prefixing to cleanly
> separate the two inside the app.
>
> /
> /frontend-controller/
>
> /admin
> /admin/backend-controller
>
> Routing like this works just fine in all cases I have ever encountered.
> And it is what 99% of all people would expect.
> One should not overengeneer stuff - its like shooting yourself in the leg
> here.
>
>
> Am Mittwoch, 26. März 2014 09:57:46 UTC+1 schrieb bato:
>>
>> Hi Mark,
>> thanks for the answer :)
>> Do you intend using Plugin for backend or frontend? However the common
>> use case we have to handle is:
>>
>>
>>- frontends and backend live on the same server and are served by the
>>same web server
>>- one backend used to manage data for two or more frontends
>>- backend and each frontends have different url. Example:
>>   - backend: http://admin.customer-name.com
>>   - frontend 1: http://site1.com
>>   - frontend 2: http://site2.org
>>   - etc...
>>
>> Is it possible handle with plugins this situation?
>>
>> On other side we like having separate app for backend and frontends
>> because it give us the possibility to use different plugins for every app
>> and have frontend as app seems more polished.
>> But if there is a simple way to handle it with plugins I like to know so
>> we can think about it.
>>
>>
>> Alberto
>>
>>
>>
>> 2014-03-26 2:41 GMT+01:00 mark_story :
>>
>>> Have you considered using plugins? If the 'backend' and 'frontend'
>>> application run in the same process/server you could probably use plugins
>>> quite nicely. If they run on separate servers it gets a bit more
>>> complicated.
>>>
>>> By using a plugin you can use basic composer features to install the
>>> backend code into the frontend one and avoid having to define the full
>>> classname everywhere as you can use Plugin.Foo style class names in most
>>> places (if there are className options that don't support Plugin.Class let
>>> us know)
>>>
>>> -Mark
>>>
>>> On Tuesday, 25 March 2014 19:19:20 UTC-4, bato wrote:

 Hi there,

 I played a bit with new ORM and now I'm starting to port BEdita to Cake
 3.
 BEdita is a Semantic Content Management Framework developed with cake
 1.3. The backend is a cake app that can manage multiple frontends data.
 Every frontend is a cake app too that uses a set of api that are exposed
 from backend app.

 Backend and frontend apps share cakephp lib and backend models,
 behaviors, helpers are reachable from frontends since they are added to
 paths with App::build().

 Now I try to figure out as reproduce the "same" situations with cake 3
 and I would ask some advice.

 I'm starting creating the backend app with composer, then I added
 frontend app by hand beacuse I want to reuse cake core installed in backend
 app.
 So my directory structure is

- bedita: containing app (Bedita\\ namespace) and vendor with
cakephp
- frontend-app: clean cakephp app skeleton


 ├── bedita
 │   ├── Bedita
 │   ├── Module
 │   ├── Plugin
 │   ├── Test
 │   ├── tmp
 │   ├── vendor
 │   └── webroot
 └── frontend-app
 ├── App
 ├── Plugin
 ├── Test
 ├── tmp
 ├── vendor
 └── webroot

 To use cake and bedita in frontend app I managed App/config/paths.phpand
 App/config/bootstrap.php

 In App/config/paths.php I added the path to bedita folder and modified
 CAKE_CORE_INCLUDE_PATH to use that.
 In App/config/bootstrap.php I change composer autoload path to 
 bedita/vendor/autoload.php
 and added to it App namespace

 // Use composer to load the autoloader.
 if (file_exists(BEDITA_CORE_PATH . '/vendor/autoload.php')) {
 $loader = require BEDITA_CORE_PATH . '/vendor/autoload.php';
 $loader->addPsr4('App\\', APP);
 }

 After that in frontend app PagesController I am able to do:

 $images = TableRegistry::get('Images', [
 'className' => 'Bedita\Model\Table\ImagesTable'
 ]);

 The only thing I had to pay attention is how to add behavior in Bedita
 Table objects. I had to specify the behavior className to avoid errors
 using those Table objects in frontend app.

 $this->addBehavior('BeditaObject', [
 'className' => 'Bedita\Model\Behavior\BeditaObjectBehavior'
 ]);


 So I

Re: cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

2014-03-26 Thread Alberto Pagliarini
Hi Mark,
thanks for the answer :)
Do you intend using Plugin for backend or frontend? However the common use
case we have to handle is:


   - frontends and backend live on the same server and are served by the
   same web server
   - one backend used to manage data for two or more frontends
   - backend and each frontends have different url. Example:
  - backend: http://admin.customer-name.com
  - frontend 1: http://site1.com
  - frontend 2: http://site2.org
  - etc...

Is it possible handle with plugins this situation?

On other side we like having separate app for backend and frontends because
it give us the possibility to use different plugins for every app and have
frontend as app seems more polished.
But if there is a simple way to handle it with plugins I like to know so we
can think about it.


Alberto



2014-03-26 2:41 GMT+01:00 mark_story :

> Have you considered using plugins? If the 'backend' and 'frontend'
> application run in the same process/server you could probably use plugins
> quite nicely. If they run on separate servers it gets a bit more
> complicated.
>
> By using a plugin you can use basic composer features to install the
> backend code into the frontend one and avoid having to define the full
> classname everywhere as you can use Plugin.Foo style class names in most
> places (if there are className options that don't support Plugin.Class let
> us know)
>
> -Mark
>
> On Tuesday, 25 March 2014 19:19:20 UTC-4, bato wrote:
>>
>> Hi there,
>>
>> I played a bit with new ORM and now I'm starting to port BEdita to Cake 3.
>> BEdita is a Semantic Content Management Framework developed with cake
>> 1.3. The backend is a cake app that can manage multiple frontends data.
>> Every frontend is a cake app too that uses a set of api that are exposed
>> from backend app.
>>
>> Backend and frontend apps share cakephp lib and backend models,
>> behaviors, helpers are reachable from frontends since they are added to
>> paths with App::build().
>>
>> Now I try to figure out as reproduce the "same" situations with cake 3
>> and I would ask some advice.
>>
>> I'm starting creating the backend app with composer, then I added
>> frontend app by hand beacuse I want to reuse cake core installed in backend
>> app.
>> So my directory structure is
>>
>>- bedita: containing app (Bedita\\ namespace) and vendor with cakephp
>>- frontend-app: clean cakephp app skeleton
>>
>>
>> ├── bedita
>> │   ├── Bedita
>> │   ├── Module
>> │   ├── Plugin
>> │   ├── Test
>> │   ├── tmp
>> │   ├── vendor
>> │   └── webroot
>> └── frontend-app
>> ├── App
>> ├── Plugin
>> ├── Test
>> ├── tmp
>> ├── vendor
>> └── webroot
>>
>> To use cake and bedita in frontend app I managed App/config/paths.phpand
>> App/config/bootstrap.php
>>
>> In App/config/paths.php I added the path to bedita folder and modified
>> CAKE_CORE_INCLUDE_PATH to use that.
>> In App/config/bootstrap.php I change composer autoload path to 
>> bedita/vendor/autoload.php
>> and added to it App namespace
>>
>> // Use composer to load the autoloader.
>> if (file_exists(BEDITA_CORE_PATH . '/vendor/autoload.php')) {
>> $loader = require BEDITA_CORE_PATH . '/vendor/autoload.php';
>> $loader->addPsr4('App\\', APP);
>> }
>>
>> After that in frontend app PagesController I am able to do:
>>
>> $images = TableRegistry::get('Images', [
>> 'className' => 'Bedita\Model\Table\ImagesTable'
>> ]);
>>
>> The only thing I had to pay attention is how to add behavior in Bedita
>> Table objects. I had to specify the behavior className to avoid errors
>> using those Table objects in frontend app.
>>
>> $this->addBehavior('BeditaObject', [
>> 'className' => 'Bedita\Model\Behavior\BeditaObjectBehavior'
>> ]);
>>
>>
>> So I ask you CakePHP core dev/guru if it is the right way to handle this
>> case or if you have some suggestion or advice.
>>
>> regards
>> Alberto
>>
>>
>>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/MHdseZKF4ts/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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.
>



-- 
-- bato ---

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http:/

Re: Using ORM Entity mutators to change value doesn't work

2014-02-19 Thread Alberto Pagliarini
Do you mean a Type class to tranform spaces in commas and reverse it? Is it
really useful?

Or do you mean a Type to jsonize, serialize?
Il 14/feb/2014 17:31 "José Lorenzo"  ha scritto:

> Thanks, for getting back. Also I realized that I wrote directly to you
> instead of the group. The types system was designed with that in mind, you
> should use it instead of entity getters and setters. I hope to post a few
> examples on that when I get more time. Maybe you can help us writing that
> specific type class and document it, that would be of great help!
>
>
> On Fri, Feb 14, 2014 at 4:04 PM, Alberto Pagliarini 
>  wrote:
>
>> Thanks José for the answer.
>>
>> Let me know what you decide and if I can help.
>> Anyway my example is born because I often need to save data in different
>> format from original (serialize/unserialize, json_encode, json_decode,
>> etc..) and I think would be cleaver do it with setter and getter.
>>
>> For serialize and json maybe I could use custom Type
>> http://book.cakephp.org/3.0/en/orm/database-basics.
>> html#adding-custom-types but I need to study how it works and for other
>> data manipulation (as in example above) define a custom type would be
>> unsuitable.
>>
>> cheers
>> alberto
>>
>>
>> 2014-02-14 14:48 GMT+01:00 José Lorenzo :
>>
>>> I need to think about this for a bit. The only reason that people seem
>>> to be wanting getters in the entity is for doing presentational formatting
>>> on the same properties as the database, which was not my original
>>> intention. I'll look into a solution for this so it is more intuitive.
>>>
>>> On Friday, February 14, 2014 11:02:39 AM UTC+1, bato wrote:
>>>>
>>>> Il giorno venerdì 14 febbraio 2014 01:57:53 UTC+1, mark_story ha
>>>> scritto:
>>>>>
>>>>> One more thing. The orm will use the getter functions when preparing
>>>>> the data to be saved. Since your getter reverses te setter. This might be
>>>>> the source of your problem.
>>>>>
>>>>>
>>>>> Yes, commenting the getter the save works as expected.
>>>> But how can I do what I was trying to do? I would expect that saving
>>>> use setter but not getter so as I can save some modified data and retireve
>>>> later in the original format.
>>>> I.e.
>>>>
>>>> saving data
>>>> original data = 'name surname' => save (use setter) => save on db
>>>> 'name,surname'
>>>>
>>>> retrieving data
>>>> saved data on db 'name,surname' => find (use getter) => original data
>>>> 'name surname'
>>>>
>>>> I know I could obtain the same results modifing original data before
>>>> saving it but I would know if there is a method using ORM properties.
>>>>
>>>> thanks for your great work
>>>> alberto
>>>>
>>>>
>>
>>
>> --
>> -- bato ---
>>
>>

-- 
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+unsubscr...@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/groups/opt_out.


Re: Help saving data with CakePHP 3.0 ORM

2014-02-05 Thread Alberto Pagliarini
Hi Carlos,

PHP 5.4 permits the ['key' => 'value'] array syntax. The issue I had was
resolved by using Entity class and $_accessible property.




2014-02-04 Carlos Javier Baeza Negroni :

> Also check the array:
> $data = ['name' => 'Walter White'];
>
> Should be:
> $data = array('name' => 'Walter White');
>
>
> best regards.
>
>
> 2014-02-04 José Lorenzo :
>
>> Currently that is the most confusing part of the ORM and I'd like to make
>> it easier to understand in the next release preview. By default entities
>> are protected agains mass assignment, this means that you cannot create
>> them without configuring what properties can be set from the request. You
>> need to create the entity class and set the properties that are accessible
>> for mass assignment. Please read this section in the book:
>>
>> http://book.cakephp.org/3.0/en/orm/entities.html#mass-assignment
>>
>>
>> On Tuesday, February 4, 2014 5:16:31 PM UTC+1, bato wrote:
>>>
>>> Hi,
>>>
>>> I'm starting to play with 3.0 ORM and I encountered some issues saving
>>> data.
>>>
>>> I have two simple tables:
>>>
>>>- authors with fields id and name
>>>- posts with fields id, title, text and author_id
>>>
>>>
>>> I have fill tables with two authors and some posts by hand to try
>>> retrieving data with cake.
>>>
>>> I have set up two Table class as:
>>>
>>> App/Model/Table/AuhtorsTable.php
>>>
>>> >>
>>> namespace App\Model\Table;
>>>
>>> use Cake\ORM\Table;
>>>
>>> class AuthorsTable extends Table {
>>>
>>> public function initialize(array $config) {
>>> $this->hasMany('Posts');
>>> }
>>>
>>> }
>>>
>>> and
>>>
>>> App/Model/Table/PostsTable.php
>>>
>>> >>
>>> namespace App\Model\Table;
>>>
>>> use Cake\ORM\Table;
>>>
>>> class PostsTable extends Table {
>>>
>>> public function initialize(array $config) {
>>> $this->belongsTo('Authors');
>>> }
>>>
>>> }
>>>
>>> In App/Controller/PagesController.php I'm trying to save data from an
>>> array.
>>>
>>> $data = ['name' => 'Walter White'];
>>> $authors = TableRegistry::get('Authors');
>>> $author = $authors->newEntity($data);
>>> $authors->save($author);
>>>
>>> The data aren't saved. The save method return false but I don't
>>> understand why.
>>> Am I missing something?
>>> I have following http://book.cakephp.org/3.0/en/orm/table-objects.
>>> html#converting-request-data-into-entities
>>>
>>> best regards
>>> alberto
>>>
>>>
>>>
>>>
>>>  --
>> 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+unsubscr...@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/groups/opt_out.
>>
>
>
>
> --
> *Carlos Baeza Negroni*
> +56985644026
> http://carlosbaeza.net
> @cjbaezilla
> http://cl.linkedin.com/in/cjbaeza
>  
>
> --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/vSUI_dJRueg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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/groups/opt_out.
>



-- 
-- bato ---

-- 
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+unsubscr...@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/groups/opt_out.


Re: Help saving data with CakePHP 3.0 ORM

2014-02-05 Thread Alberto Pagliarini
Yeah!

using Entity class and $_accessible property all works as expected!

thanks
José


2014-02-04 José Lorenzo :

> Currently that is the most confusing part of the ORM and I'd like to make
> it easier to understand in the next release preview. By default entities
> are protected agains mass assignment, this means that you cannot create
> them without configuring what properties can be set from the request. You
> need to create the entity class and set the properties that are accessible
> for mass assignment. Please read this section in the book:
>
> http://book.cakephp.org/3.0/en/orm/entities.html#mass-assignment
>
>
> On Tuesday, February 4, 2014 5:16:31 PM UTC+1, bato wrote:
>>
>> Hi,
>>
>> I'm starting to play with 3.0 ORM and I encountered some issues saving
>> data.
>>
>> I have two simple tables:
>>
>>- authors with fields id and name
>>- posts with fields id, title, text and author_id
>>
>>
>> I have fill tables with two authors and some posts by hand to try
>> retrieving data with cake.
>>
>> I have set up two Table class as:
>>
>> App/Model/Table/AuhtorsTable.php
>>
>> >
>> namespace App\Model\Table;
>>
>> use Cake\ORM\Table;
>>
>> class AuthorsTable extends Table {
>>
>> public function initialize(array $config) {
>> $this->hasMany('Posts');
>> }
>>
>> }
>>
>> and
>>
>> App/Model/Table/PostsTable.php
>>
>> >
>> namespace App\Model\Table;
>>
>> use Cake\ORM\Table;
>>
>> class PostsTable extends Table {
>>
>> public function initialize(array $config) {
>> $this->belongsTo('Authors');
>> }
>>
>> }
>>
>> In App/Controller/PagesController.php I'm trying to save data from an
>> array.
>>
>> $data = ['name' => 'Walter White'];
>> $authors = TableRegistry::get('Authors');
>> $author = $authors->newEntity($data);
>> $authors->save($author);
>>
>> The data aren't saved. The save method return false but I don't
>> understand why.
>> Am I missing something?
>> I have following http://book.cakephp.org/3.0/en/orm/table-objects.
>> html#converting-request-data-into-entities
>>
>> best regards
>> alberto
>>
>>
>>
>>
>>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/vSUI_dJRueg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@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/groups/opt_out.
>



-- 
-- bato ---

-- 
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+unsubscr...@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/groups/opt_out.


Re: Poll: what do you hate about CakePHP?

2009-05-08 Thread Alberto Pagliarini

Simple way to initialize a component on the fly.

ClassRegistry::init is very useful for model... I'd like it (or
something similar) works with component


-- 
-- bato ---

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---