CakePHP 3.0.0-alpha2 released

2014-07-28 Thread José Lorenzo


The CakePHP core team is proud to announce the immediate availability of 
CakePHP 
3.0.0-alpha2 https://github.com/cakephp/cakephp/releases/3.0.0-alpha2. 
CakePHP 3.0.0-alpha2 is the second alpha release for CakePHP 3.0.0. In the 
month since 3.0.0-alpha1 a few new features have been merged, and many 
issues have been fixed.
New Features in 3.0.0-alpha2Router Refactor and Builder Based APIs.

The Router class has been re-factored internally and new methods have been 
added to allow your routes file to stay DRYer than ever before. In addition 
to improved methods, the performance of parsing incoming URLs has been 
greatly improved. Router is stricter about missing routes, and will notify 
you (via an exception) when a URL cannot be parsed or matched with the 
connected routes.

The default routes provided by CakePHP have been removed. While helpful in 
the prototyping stages, these routes created issues with duplicate content 
and were often not used in larger applications. In their place, a smaller 
subset of routes is provided to help with the prototype stage of 
application development. If you have an existing application using 3.0, you 
will need to update your routes.php 
https://github.com/cakephp/app/blob/master/src/Config/routes.php file.
CacheHelper Removed

CacheHelper has been removed from CakePHP. The core team feels that the 
functionality this helper provided is best handled by standalone servers 
like Varnish http://varnish-cache.org/. While we explored building a ESI 
based replacement for CacheHelper, there were a number of edge cases that 
would have complicated the implementation.
ORM Improvements
   
   - Empty associations in BelongsTo and HasOne associations no longer 
   hydrate an empty entity. Instead the association property will be null .
   - Options for all the various ORM operations are now consistent.
   - You can specify a white list of fields when marshaling data out of the 
   request and into entities.
   - It is now easier to implement custom column types with the 
   _initializeSchema table hook method.
   - Query::newExpr() now accepts a SQL expression.
   - Conditions with nullable values are easier to build 'field IS' = $val 
will 
   generate correct SQL when $val is not NULL .
   - Conditions with IN clauses work better with empty data.

Other Changes
   
   - HtmlHelper and FormHelper had their $confirmMessage arguments removed 
   and replaced with confirm options.
   - Improved errors for Cells.
   - Prefixed controllers can now use prefixed layouts which will be 
   checked automatically.
   - Cookies are now read and decrypted lazily.
   - The ssl routing option is now _ssl .
   - The [method] routing option is now _method .
   - Header based route matching has been removed. It was very infrequently 
   used.
   - Router::resourceMap() has been removed. New options for 
   Router::mapResources() replace the need to have this method.
   - Bcrypt hashing has been removed from Security::hash()

There are still tickets available for CakeFest 2014. You can get your 
tickets now http://cakefest.org/tickets to join us in Madrid for exciting 
talks and tutorials on CakePHP and related technologies.

For more details on all the changes in 3.0.0, you can consult the migration 
guide http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html. 
I'd like to thank everyone who has contributed thoughts, code, 
documentation or feedback to 3.0 so far. We are very grateful for all the 
early adopters and their feedback. Getting issues found and fixed early is 
a huge help.

-- 
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: Behavior method won't work

2014-07-28 Thread Sam Clauw
Okay, I think I got it. I've made a single function as you suggested.

*Controller*

public function delete($id)
 {
 if ($this-request-is('get')) {
 throw new MethodNotAllowedException();
 }
 
 $this-Attraction-id = $id;
 
 if ($this-Attraction-softDelete($id)) {
 $this-Session-setFlash(__('The attraction with id %s was 
 successfully deleted.', h($id)), 'default', array(
 'class' = 'alert alert-success'
 ));
 }
 
 return $this-redirect(array(
 'action' = 'index'
 ));
 }


*AppModel*

 class AppModel extends Model {
 
 // Soft delete functionaliteit
 
 public function beforeDelete()
 {
 if ($this-hasField('deleted')) {
 $this-saveField('deleted', date('Y-m-d H:i:s'));
 }
 
 return false;
 }
 
 public function softDelete($id)
 {
 $this-delete($id);
 
 $record = $this-find('count', array(
 'conditions' = array(
 {$this-alias}.id = $id,
 {$this-alias}.deleted != = null
 )
 ));
 if ($record  0) {
 return true;
 }
 }
 }


And that works fine for me now! Stephen, thank you for you time and thank 
you very much to support me on this one!
I've pasted my code here so others can use this functionality too! ;)

-- 
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: CakePHP 3.0.0-alpha2 released

2014-07-28 Thread Dr. Tarique Sani
Hey Mark,

I know it will be done when it is done but can't resist asking none the
less - any ETA on the Debug Toolkit for v3 ?

TIA

Tarique


On Mon, Jul 28, 2014 at 12:43 PM, José Lorenzo jose@gmail.com wrote:

 The CakePHP core team is proud to announce the immediate availability of 
 CakePHP
 3.0.0-alpha2 https://github.com/cakephp/cakephp/releases/3.0.0-alpha2.
 CakePHP 3.0.0-alpha2 is the second alpha release for CakePHP 3.0.0. In the
 month since 3.0.0-alpha1 a few new features have been merged, and many
 issues have been fixed.
 New Features in 3.0.0-alpha2Router Refactor and Builder Based APIs.

 The Router class has been re-factored internally and new methods have been
 added to allow your routes file to stay DRYer than ever before. In addition
 to improved methods, the performance of parsing incoming URLs has been
 greatly improved. Router is stricter about missing routes, and will notify
 you (via an exception) when a URL cannot be parsed or matched with the
 connected routes.

 The default routes provided by CakePHP have been removed. While helpful in
 the prototyping stages, these routes created issues with duplicate content
 and were often not used in larger applications. In their place, a smaller
 subset of routes is provided to help with the prototype stage of
 application development. If you have an existing application using 3.0, you
 will need to update your routes.php
 https://github.com/cakephp/app/blob/master/src/Config/routes.php file.
 CacheHelper Removed

 CacheHelper has been removed from CakePHP. The core team feels that the
 functionality this helper provided is best handled by standalone servers
 like Varnish http://varnish-cache.org/. While we explored building a
 ESI based replacement for CacheHelper, there were a number of edge cases
 that would have complicated the implementation.
 ORM Improvements

- Empty associations in BelongsTo and HasOne associations no longer
hydrate an empty entity. Instead the association property will be null
.
- Options for all the various ORM operations are now consistent.
- You can specify a white list of fields when marshaling data out of
the request and into entities.
- It is now easier to implement custom column types with the
_initializeSchema table hook method.
- Query::newExpr() now accepts a SQL expression.
- Conditions with nullable values are easier to build
'field IS' = $val will generate correct SQL when $val is not NULL .
- Conditions with IN clauses work better with empty data.

 Other Changes

- HtmlHelper and FormHelper had their $confirmMessage arguments
removed and replaced with confirm options.
- Improved errors for Cells.
- Prefixed controllers can now use prefixed layouts which will be
checked automatically.
- Cookies are now read and decrypted lazily.
- The ssl routing option is now _ssl .
- The [method] routing option is now _method .
- Header based route matching has been removed. It was very
infrequently used.
- Router::resourceMap() has been removed. New options for
Router::mapResources() replace the need to have this method.
- Bcrypt hashing has been removed from Security::hash()

 There are still tickets available for CakeFest 2014. You can get your
 tickets now http://cakefest.org/tickets to join us in Madrid for
 exciting talks and tutorials on CakePHP and related technologies.

 For more details on all the changes in 3.0.0, you can consult the migration
 guide http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html.
 I'd like to thank everyone who has contributed thoughts, code,
 documentation or feedback to 3.0 so far. We are very grateful for all the
 early adopters and their feedback. Getting issues found and fixed early is
 a huge help.

 --
 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.




-- 
=
The Conference Schedule Creator : http://shdlr.com

PHP for E-Biz : http://sanisoft.com
=

-- 
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 

Re: CakePHP 3.0.0-alpha2 released

2014-07-28 Thread José Lorenzo
Once we release the beta we are going to focus more in plugins, such as 
debug kit. Beta is hopefully the next release :)

On Monday, July 28, 2014 1:50:16 PM UTC+2, Dr. Tarique Sani wrote:

 Hey Mark,

 I know it will be done when it is done but can't resist asking none the 
 less - any ETA on the Debug Toolkit for v3 ?

 TIA

 Tarique


 On Mon, Jul 28, 2014 at 12:43 PM, José Lorenzo jose@gmail.com wrote:

 The CakePHP core team is proud to announce the immediate availability of 
 CakePHP 
 3.0.0-alpha2 https://github.com/cakephp/cakephp/releases/3.0.0-alpha2. 
 CakePHP 3.0.0-alpha2 is the second alpha release for CakePHP 3.0.0. In the 
 month since 3.0.0-alpha1 a few new features have been merged, and many 
 issues have been fixed.
 New Features in 3.0.0-alpha2 Router Refactor and Builder Based APIs.

 The Router class has been re-factored internally and new methods have 
 been added to allow your routes file to stay DRYer than ever before. In 
 addition to improved methods, the performance of parsing incoming URLs has 
 been greatly improved. Router is stricter about missing routes, and will 
 notify you (via an exception) when a URL cannot be parsed or matched with 
 the connected routes.

 The default routes provided by CakePHP have been removed. While helpful 
 in the prototyping stages, these routes created issues with duplicate 
 content and were often not used in larger applications. In their place, a 
 smaller subset of routes is provided to help with the prototype stage of 
 application development. If you have an existing application using 3.0, you 
 will need to update your routes.php 
 https://github.com/cakephp/app/blob/master/src/Config/routes.php file.
 CacheHelper Removed

 CacheHelper has been removed from CakePHP. The core team feels that the 
 functionality this helper provided is best handled by standalone servers 
 like Varnish http://varnish-cache.org/. While we explored building a 
 ESI based replacement for CacheHelper, there were a number of edge cases 
 that would have complicated the implementation.
 ORM Improvements

- Empty associations in BelongsTo and HasOne associations no longer 
hydrate an empty entity. Instead the association property will be null
 . 
- Options for all the various ORM operations are now consistent. 
- You can specify a white list of fields when marshaling data out of 
the request and into entities. 
- It is now easier to implement custom column types with the 
_initializeSchema table hook method. 
- Query::newExpr() now accepts a SQL expression. 
- Conditions with nullable values are easier to build 
'field IS' = $val will generate correct SQL when $val is not NULL . 
- Conditions with IN clauses work better with empty data. 

 Other Changes

- HtmlHelper and FormHelper had their $confirmMessage arguments 
removed and replaced with confirm options. 
- Improved errors for Cells. 
- Prefixed controllers can now use prefixed layouts which will be 
checked automatically. 
- Cookies are now read and decrypted lazily. 
- The ssl routing option is now _ssl . 
- The [method] routing option is now _method . 
- Header based route matching has been removed. It was very 
infrequently used. 
- Router::resourceMap() has been removed. New options for 
Router::mapResources() replace the need to have this method. 
- Bcrypt hashing has been removed from Security::hash() 

 There are still tickets available for CakeFest 2014. You can get your 
 tickets now http://cakefest.org/tickets to join us in Madrid for 
 exciting talks and tutorials on CakePHP and related technologies.

 For more details on all the changes in 3.0.0, you can consult the migration 
 guide 
 http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html. 
 I'd like to thank everyone who has contributed thoughts, code, 
 documentation or feedback to 3.0 so far. We are very grateful for all the 
 early adopters and their feedback. Getting issues found and fixed early is 
 a huge help.
  
 -- 
 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.




 -- 
 =
 The Conference Schedule Creator : http://shdlr.com

 PHP for E-Biz : http://sanisoft.com
 = 


-- 
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 

CakePHP 3.0.0-alpha2 released

2014-07-28 Thread mark_story
The CakePHP core team is proud to announce the immediate availability of 
[CakePHP 
3.0.0-alpha2](https://github.com/cakephp/cakephp/releases/3.0.0-alpha2). 
CakePHP 3.0.0-alpha2 is the second alpha release for CakePHP 3.0.0. In the 
month since 3.0.0-alpha1 a few new features have been merged, and many 
issues have been fixed.

## New Features in 3.0.0-alpha2

### Router Refactor and Builder Based APIs.

The Router class has been re-factored internally and new methods have been 
added to allow your routes file to stay DRYer than ever before. In addition 
to improved methods, the performance of parsing incoming URLs has been 
greatly improved. Router is stricter about missing routes, and will notify 
you (via an exception) when a URL cannot be parsed or matched with the 
connected routes.

The default routes provided by CakePHP have been removed. While helpful in 
the prototyping stages, these routes created issues with duplicate content 
and were often not used in larger applications. In their place, a smaller 
subset of routes is provided to help with the prototype stage of 
application development. If you have an existing application using 3.0, you 
will need to update your 
[routes.php](https://github.com/cakephp/app/blob/master/src/Config/routes.php) 
file.

### CacheHelper Removed

CacheHelper has been removed from CakePHP. The core team feels that the 
functionality this helper provided is best handled by standalone servers 
like [Varnish](http://varnish-cache.org). While we explored building a ESI 
based replacement for CacheHelper, there were a number of edge cases that 
would have complicated the implementation.

### ORM Improvements

* Empty associations in BelongsTo and HasOne associations no longer hydrate 
an empty entity. Instead the association property will be `null`.
* Options for all the various ORM operations are now consistent.
* You can specify a white list of fields when marshaling data out of the 
request and into entities.
* It is now easier to implement custom column types with the 
`_initializeSchema` table hook method.
* Query::newExpr() now accepts a SQL expression.
* Conditions with nullable values are easier to build `'field IS' = $val` 
will generate correct SQL when `$val` is not `NULL`.
* Conditions with `IN` clauses work better with empty data.

### Other Changes

* HtmlHelper and FormHelper had their `$confirmMessage` arguments removed 
and replaced with `confirm` options.
* Improved errors for Cells.
* Prefixed controllers can now use prefixed layouts which will be checked 
automatically.
* Cookies are now read and decrypted lazily.
* The `ssl` routing option is now `_ssl`.
* The `[method]` routing option is now `_method`.
* Header based route matching has been removed. It was very infrequently 
used.
* Router::resourceMap() has been removed. New options for 
Router::mapResources() replace the need to have this method.
* Bcrypt hashing has been removed from `Security::hash()`

There are still tickets available for CakeFest 2014. You can get [your 
tickets now](http://cakefest.org/tickets) to join us in Madrid for exciting 
talks and tutorials on CakePHP and related technologies.

For more details on all the changes in 3.0.0, you can consult the 
[migration 
guide](http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html). 
I'd like to thank everyone who has contributed thoughts, code, 
documentation or feedback to 3.0 so far. We are very grateful for all the 
early adopters and their feedback. Getting issues found and fixed early is 
a huge help.

-- 
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.


3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread Bernhard Minatti
Hello!

I'm trying to add the same behaviour to multiple Tables, which are related 
to each other. Thus i created a class SpecialBehaviour, which is included 
in both Tables in their initialize() method:
$this-addBehavior('SpecialBehaviour');

It works fine, when only one of the tables is queried, but when executing a 
Query that joins the two tables together, an error is thrown:
*Cannot redeclare class Cake\Model\Behavior\SpecialBehavior*

Is there another way to add a global behavior to multiple tables?

thanks in advance!

-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread José Lorenzo
Can you show where you created that behavior class?. It would be nice if 
you can gist your Tables as well

On Monday, July 28, 2014 3:43:35 PM UTC+2, Bernhard Minatti wrote:

 Hello!

 I'm trying to add the same behaviour to multiple Tables, which are related 
 to each other. Thus i created a class SpecialBehaviour, which is included 
 in both Tables in their initialize() method:
 $this-addBehavior('SpecialBehaviour');

 It works fine, when only one of the tables is queried, but when executing 
 a Query that joins the two tables together, an error is thrown:
 *Cannot redeclare class Cake\Model\Behavior\SpecialBehavior*

 Is there another way to add a global behavior to multiple tables?

 thanks in advance!


-- 
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: CakePHP 3.0.0-alpha2 released

2014-07-28 Thread mark_story
I'll probably start on it very soon as most of the 'big' work items I 
wanted to get done for 3.0 are now complete.

-Mark

On Monday, 28 July 2014 07:50:16 UTC-4, Dr. Tarique Sani wrote:

 Hey Mark,

 I know it will be done when it is done but can't resist asking none the 
 less - any ETA on the Debug Toolkit for v3 ?

 TIA

 Tarique


 On Mon, Jul 28, 2014 at 12:43 PM, José Lorenzo jose@gmail.com wrote:

 The CakePHP core team is proud to announce the immediate availability of 
 CakePHP 
 3.0.0-alpha2 https://github.com/cakephp/cakephp/releases/3.0.0-alpha2. 
 CakePHP 3.0.0-alpha2 is the second alpha release for CakePHP 3.0.0. In the 
 month since 3.0.0-alpha1 a few new features have been merged, and many 
 issues have been fixed.
 New Features in 3.0.0-alpha2 Router Refactor and Builder Based APIs.

 The Router class has been re-factored internally and new methods have 
 been added to allow your routes file to stay DRYer than ever before. In 
 addition to improved methods, the performance of parsing incoming URLs has 
 been greatly improved. Router is stricter about missing routes, and will 
 notify you (via an exception) when a URL cannot be parsed or matched with 
 the connected routes.

 The default routes provided by CakePHP have been removed. While helpful 
 in the prototyping stages, these routes created issues with duplicate 
 content and were often not used in larger applications. In their place, a 
 smaller subset of routes is provided to help with the prototype stage of 
 application development. If you have an existing application using 3.0, you 
 will need to update your routes.php 
 https://github.com/cakephp/app/blob/master/src/Config/routes.php file.
 CacheHelper Removed

 CacheHelper has been removed from CakePHP. The core team feels that the 
 functionality this helper provided is best handled by standalone servers 
 like Varnish http://varnish-cache.org/. While we explored building a 
 ESI based replacement for CacheHelper, there were a number of edge cases 
 that would have complicated the implementation.
 ORM Improvements

- Empty associations in BelongsTo and HasOne associations no longer 
hydrate an empty entity. Instead the association property will be null
 . 
- Options for all the various ORM operations are now consistent. 
- You can specify a white list of fields when marshaling data out of 
the request and into entities. 
- It is now easier to implement custom column types with the 
_initializeSchema table hook method. 
- Query::newExpr() now accepts a SQL expression. 
- Conditions with nullable values are easier to build 
'field IS' = $val will generate correct SQL when $val is not NULL . 
- Conditions with IN clauses work better with empty data. 

 Other Changes

- HtmlHelper and FormHelper had their $confirmMessage arguments 
removed and replaced with confirm options. 
- Improved errors for Cells. 
- Prefixed controllers can now use prefixed layouts which will be 
checked automatically. 
- Cookies are now read and decrypted lazily. 
- The ssl routing option is now _ssl . 
- The [method] routing option is now _method . 
- Header based route matching has been removed. It was very 
infrequently used. 
- Router::resourceMap() has been removed. New options for 
Router::mapResources() replace the need to have this method. 
- Bcrypt hashing has been removed from Security::hash() 

 There are still tickets available for CakeFest 2014. You can get your 
 tickets now http://cakefest.org/tickets to join us in Madrid for 
 exciting talks and tutorials on CakePHP and related technologies.

 For more details on all the changes in 3.0.0, you can consult the migration 
 guide 
 http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html. 
 I'd like to thank everyone who has contributed thoughts, code, 
 documentation or feedback to 3.0 so far. We are very grateful for all the 
 early adopters and their feedback. Getting issues found and fixed early is 
 a huge help.
  
 -- 
 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.




 -- 
 =
 The Conference Schedule Creator : http://shdlr.com

 PHP for E-Biz : http://sanisoft.com
 = 


-- 
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 

Re: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread Bernhard Minatti
my files are as follows:

src/Model/Behavior/SpecialBehavior.php
namespace Cake\Model\Behavior;

use Cake\Event\Event;
use Cake\ORM\Behavior;
use Cake\ORM\Query;
use Cake\Network\Request;
use Cake\Network\Session;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Controller\Component\AuthComponent;

class SpecialBehavior extends Behavior {
public function beforeFind(Event $event, $query) {
//do stuff
}
}


src/Model/Table/SitesTable.php
?php

namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

class SitesTable extends Table {

public function initialize(array $config) {
$this-addBehavior('Site');
$this-addBehavior('Special');
}
}

src/Model/Table/CategoriesTable.php
?php

namespace App\Model\Table;

use Cake\ORM\Table;

class CategoriesTable extends Table {

public function initialize(array $config) {
$this-addBehavior('Special');
}

public function validationDefault(Validator $validator) {
return $validator
-notEmpty('name', 'A name is required');
}

}



thanks in advance!



Am Montag, 28. Juli 2014 16:02:03 UTC+2 schrieb José Lorenzo:

 Can you show where you created that behavior class?. It would be nice if 
 you can gist your Tables as well

 On Monday, July 28, 2014 3:43:35 PM UTC+2, Bernhard Minatti wrote:

 Hello!

 I'm trying to add the same behaviour to multiple Tables, which are 
 related to each other. Thus i created a class SpecialBehaviour, which is 
 included in both Tables in their initialize() method:
 $this-addBehavior('SpecialBehaviour');

 It works fine, when only one of the tables is queried, but when executing 
 a Query that joins the two tables together, an error is thrown:
 *Cannot redeclare class Cake\Model\Behavior\SpecialBehavior*

 Is there another way to add a global behavior to multiple tables?

 thanks in advance!



-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread José Lorenzo
Can you also paste the full error you are getting?

-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread Bernhard Minatti
the error is as follows:
[28-Jul-2014 16:14:06 UTC] PHP Fatal error:  Cannot redeclare class 
Cake\Model\Behavior\SpecialBehavior in 
/Applications/MAMP/htdocs/hometeam/src/Model/Behavior/SpecialBehavior.php 
on line 38

this comes directy from the php error log, cakephp itself does not log 
anything.

Am Montag, 28. Juli 2014 19:02:38 UTC+2 schrieb José Lorenzo:

 Can you also paste the full error you are getting?

-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread José Lorenzo
Hmm, that's very odd. Can you add a die(stackTrace()); at the top of that 
file after the namespace declaration?

Also try looking for the string 'SpecialBehavior' in your project, there 
must be another class with that same name that you are loading somehow.

On Monday, July 28, 2014 8:16:08 PM UTC+2, Bernhard Minatti wrote:

 the error is as follows:
 [28-Jul-2014 16:14:06 UTC] PHP Fatal error:  Cannot redeclare class 
 Cake\Model\Behavior\SpecialBehavior in 
 /Applications/MAMP/htdocs/hometeam/src/Model/Behavior/SpecialBehavior.php 
 on line 38

 this comes directy from the php error log, cakephp itself does not log 
 anything.

 Am Montag, 28. Juli 2014 19:02:38 UTC+2 schrieb José Lorenzo:

 Can you also paste the full error you are getting?



-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread José Lorenzo
Just a crazy idea, can you verify that in all places you have used the same 
casing? For example in some places you may have used 'sites' whereas in 
others 'Sites', there migh be a bug around using different casing there.

On Monday, July 28, 2014 9:13:15 PM UTC+2, Bernhard Minatti wrote:

 hmmm...

 stackTrace() does not output anything, but using debug_print_backtrace() i 
 get:

 #0  include() called at 
 [/Applications/MAMP/htdocs/vendor/composer/ClassLoader.php:382]
 #1  
 Composer\Autoload\includeFile(/Applications/MAMP/htdocs/src/Model/Behavior/SpecialBehavior.php)
  called at [/Applications/MAMP/htdocs/vendor/composer/ClassLoader.php:274]
 #2  
 Composer\Autoload\ClassLoader-loadClass(App\Model\Behavior\SpecialBehavior)
 #3  spl_autoload_call(App\Model\Behavior\SpecialBehavior)
 #4  class_exists(App\Model\Behavior\SpecialBehavior) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/Core/App.php:113]
 #5  Cake\Core\App::_classExistsInBase(\Model\Behavior\SpecialBehavior, App) 
 called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/Core/App.php:91]
 #6  Cake\Core\App::className(Special, Model/Behavior, Behavior) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/ORM/BehaviorRegistry.php:74]
 #7  Cake\ORM\BehaviorRegistry-_resolveClassName(Special) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/Utility/ObjectRegistry.php:74]
 #8  Cake\Utility\ObjectRegistry-load(Special, Array ()) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/ORM/Table.php:490]
 #9  Cake\ORM\Table-addBehavior(Special) called at 
 [/Applications/MAMP/htdocs/src/Model/Table/SitesTable.php:12]
 #10 App\Model\Table\SitesTable-initialize(Array ([alias] = 
 Sites,[className] = App\Model\Table\SitesTable,[connection] = 
 Cake\Database\Connection Object ([] = Array ([driver] = 
 Cake\Database\Driver\Mysql,[persistent] = ,[host] = localhost,[login] = 
 root,[password] = root,[database] = hometeam,[prefix] = ,[encoding] = 
 utf8,[timezone] = UTC,[log] = ,[cacheMetadata] = 1,[name] = default),[] 
 = Cake\Database\Driver\Mysql Object ([] = Array ([persistent] = 1,[host] 
 = localhost,[login] = root,[password] = ,[database] = cake,[port] = 
 3306,[flags] = Array (),[encoding] = utf8,[timezone] = ,[init] = Array 
 (),[dsn] = ),[] = Array ([driver] = 
 Cake\Database\Driver\Mysql,[persistent] = ,[host] = localhost,[login] = 
 root,[password] = root,[database] = hometeam,[prefix] = ,[encoding] = 
 utf8,[timezone] = UTC,[log] = ,[cacheMetadata] = 1,[name] = 
 default,[port] = 3306,[flags] = Array (),[init] = Array (),[dsn] = ),[] 
 = ,[] = `,[] = `,[] = ,[] = ),[] = 0,[] = ,[] = ,[] = ,[] = ))) 
 called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/ORM/Table.php:216]
 #11 Cake\ORM\Table-__construct(Array ([alias] = Sites,[className] = 
 App\Model\Table\SitesTable,[connection] = Cake\Database\Connection Object 
 ([] = Array ([driver] = Cake\Database\Driver\Mysql,[persistent] = ,[host] 
 = localhost,[login] = root,[password] = root,[database] = 
 hometeam,[prefix] = ,[encoding] = utf8,[timezone] = UTC,[log] = 
 ,[cacheMetadata] = 1,[name] = default),[] = Cake\Database\Driver\Mysql 
 Object ([] = Array ([persistent] = 1,[host] = localhost,[login] = 
 root,[password] = ,[database] = cake,[port] = 3306,[flags] = Array 
 (),[encoding] = utf8,[timezone] = ,[init] = Array (),[dsn] = ),[] = 
 Array ([driver] = Cake\Database\Driver\Mysql,[persistent] = ,[host] = 
 localhost,[login] = root,[password] = root,[database] = hometeam,[prefix] 
 = ,[encoding] = utf8,[timezone] = UTC,[log] = ,[cacheMetadata] = 
 1,[name] = default,[port] = 3306,[flags] = Array (),[init] = Array 
 (),[dsn] = ),[] = ,[] = `,[] = `,[] = ,[] = ),[] = 0,[] = ,[] = ,[] 
 = ,[] = ))) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/ORM/TableRegistry.php:166]
 #12 Cake\ORM\TableRegistry::get(Sites) called at 
 [/Applications/MAMP/htdocs/vendor/cakephp/cakephp/src/Model/ModelAwareTrait.php:95]
 #13 Cake\Controller\Controller-loadModel(Sites) called at 
 [/Applications/MAMP/htdocs/src/Controller/CategoriesController.php:16]
 #14 App\Controller\CategoriesController-add()
 #15 ReflectionMethod-invokeArgs(App\Controller\CategoriesController Object 
 ([helpers] = Array ([Form] = Array ([className] = 
 BootstrapForm),[BootstrapHTML] = ),[components] = Array ([Flash] = 
 ,[Session] = ,[Auth] = Array ([loginRedirect] = Array ([controller] = 
 Users,[action] = index),[logoutRedirect] = Array ([controller] = 
 Pages,[action] = display,[0] = home)),[Acl] = ),[name] = 
 Categories,[request] = Cake\Network\Request Object ([params] = Array 
 ([plugin] = ,[controller] = Categories,[action] = add,[_ext] = ,[pass] = 
 Array ()),[data] = Array (),[query] = Array (),[cookies] = Array 
 ([SQLiteManager_currentLangue] = 4,[CAKEPHP] = 
 db44d6a517c05632401039e3304a7d07),[] = Array ([REDIRECT_REDIRECT_STATUS] = 
 200,[REDIRECT_STATUS] = 200,[HTTP_HOST] = localhost:,[HTTP_USER_AGENT] 
 = Mozilla/5.0 

CakePHP 3.0 Validation ?

2014-07-28 Thread Mikaël Capelle
Hi everyone,

I'm trying to build a new CakePHP 3 application but I didn't manage to get 
the data validation working... I followed the CakePHP 3.0 book, and 
particulary this 
page http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
but it didn't help.

Currently, my Table is as follow:

class DevoirsTable extends Table {
 
public function initialize(array $config) {
 
}

public function validationDefault (Validator $validator) {
debug('TEST HERE') ;
$validator-notEmpty('pseudo', 'Oh my god!');
return $validator;
} 
 }


And my controller:

$this-Devoirs = TableRegistry::get('Devoirs') ;
$devoir = $this-Devoirs-find()-first() ;
if ($this-request-is(['post', 'put'])) {
$this-Devoirs-patchEntity($devoir, $this-request-data) ;
$this-set('saved', $this-Devoirs-save($devoir, ['validate' = 
true])) ;
}


This is only a test action, the row is correctly updated in my database but 
the 'TEST HERE' string never showed up... I don't understand how the new 
validation system works, maybe someone can help me?

Thanks,

-- 
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: CakePHP 3.0 Validation ?

2014-07-28 Thread José Lorenzo
A few questions:

- Where did you put DevoirsTable ?
- How did you name the DevoirsTable file?
- What namespace did you use in that file?
- Can you verify that file is being included?

And a small correction, This is not needed in a DevoirsController:

$this-Devoirs = TableRegistry::get('Devoirs');


On Monday, July 28, 2014 10:20:06 PM UTC+2, Mikaël Capelle wrote:

 Hi everyone,

 I'm trying to build a new CakePHP 3 application but I didn't manage to get 
 the data validation working... I followed the CakePHP 3.0 book, and 
 particulary this page 
 http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
 but it didn't help.

 Currently, my Table is as follow:

 class DevoirsTable extends Table {
  
 public function initialize(array $config) {
  
 }
 
 public function validationDefault (Validator $validator) {
 debug('TEST HERE') ;
 $validator-notEmpty('pseudo', 'Oh my god!');
 return $validator;
 } 
  }


 And my controller:

 $this-Devoirs = TableRegistry::get('Devoirs') ;
 $devoir = $this-Devoirs-find()-first() ;
 if ($this-request-is(['post', 'put'])) {
 $this-Devoirs-patchEntity($devoir, $this-request-data) ;
 $this-set('saved', $this-Devoirs-save($devoir, ['validate' = 
 true])) ;
 }


 This is only a test action, the row is correctly updated in my database 
 but the 'TEST HERE' string never showed up... I don't understand how the 
 new validation system works, maybe someone can help me?

 Thanks,



-- 
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: CakePHP 3.0 Validation ?

2014-07-28 Thread Mikaël Capelle
I'm not in DevoirsController. 

Thanks to your questions, I found my mistake, I named the file 
DevoirsTable.ctp instead of DevoirsTable.php... Stupid copy/paste mistake, 
thanks you for pointing me to this!

On Monday, July 28, 2014 10:54:33 PM UTC+2, José Lorenzo wrote:

 A few questions:

 - Where did you put DevoirsTable ?
 - How did you name the DevoirsTable file?
 - What namespace did you use in that file?
 - Can you verify that file is being included?

 And a small correction, This is not needed in a DevoirsController:

 $this-Devoirs = TableRegistry::get('Devoirs');


 On Monday, July 28, 2014 10:20:06 PM UTC+2, Mikaël Capelle wrote:

 Hi everyone,

 I'm trying to build a new CakePHP 3 application but I didn't manage to 
 get the data validation working... I followed the CakePHP 3.0 book, and 
 particulary this page 
 http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
 but it didn't help.

 Currently, my Table is as follow:

 class DevoirsTable extends Table {
  
 public function initialize(array $config) {
  
 }
 
 public function validationDefault (Validator $validator) {
 debug('TEST HERE') ;
 $validator-notEmpty('pseudo', 'Oh my god!');
 return $validator;
 } 
  }


 And my controller:

 $this-Devoirs = TableRegistry::get('Devoirs') ;
 $devoir = $this-Devoirs-find()-first() ;
 if ($this-request-is(['post', 'put'])) {
 $this-Devoirs-patchEntity($devoir, $this-request-data) ;
 $this-set('saved', $this-Devoirs-save($devoir, ['validate' = 
 true])) ;
 }


 This is only a test action, the row is correctly updated in my database 
 but the 'TEST HERE' string never showed up... I don't understand how the 
 new validation system works, maybe someone can help me?

 Thanks,



-- 
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: CakePHP 3.0 Validation ?

2014-07-28 Thread José Lorenzo
You can also use $this-loadModel('Devoirs'); in the controller

Glad you found the problem

On Monday, July 28, 2014 11:10:09 PM UTC+2, Mikaël Capelle wrote:

 I'm not in DevoirsController. 

 Thanks to your questions, I found my mistake, I named the file 
 DevoirsTable.ctp instead of DevoirsTable.php... Stupid copy/paste mistake, 
 thanks you for pointing me to this!

 On Monday, July 28, 2014 10:54:33 PM UTC+2, José Lorenzo wrote:

 A few questions:

 - Where did you put DevoirsTable ?
 - How did you name the DevoirsTable file?
 - What namespace did you use in that file?
 - Can you verify that file is being included?

 And a small correction, This is not needed in a DevoirsController:

 $this-Devoirs = TableRegistry::get('Devoirs');


 On Monday, July 28, 2014 10:20:06 PM UTC+2, Mikaël Capelle wrote:

 Hi everyone,

 I'm trying to build a new CakePHP 3 application but I didn't manage to 
 get the data validation working... I followed the CakePHP 3.0 book, and 
 particulary this page 
 http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
 but it didn't help.

 Currently, my Table is as follow:

 class DevoirsTable extends Table {
  
 public function initialize(array $config) {
  
 }
 
 public function validationDefault (Validator $validator) {
 debug('TEST HERE') ;
 $validator-notEmpty('pseudo', 'Oh my god!');
 return $validator;
 } 
  }


 And my controller:

 $this-Devoirs = TableRegistry::get('Devoirs') ;
 $devoir = $this-Devoirs-find()-first() ;
 if ($this-request-is(['post', 'put'])) {
 $this-Devoirs-patchEntity($devoir, $this-request-data) ;
 $this-set('saved', $this-Devoirs-save($devoir, ['validate' = 
 true])) ;
 }


 This is only a test action, the row is correctly updated in my database 
 but the 'TEST HERE' string never showed up... I don't understand how the 
 new validation system works, maybe someone can help me?

 Thanks,



-- 
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: 3.x: Same Behaviour for Multiple Tables

2014-07-28 Thread euromark
Why are you using

namespace Cake\Model\Behavior;

in your behavior?
The namespace should cleary be App\...

mark


Am Montag, 28. Juli 2014 15:43:35 UTC+2 schrieb Bernhard Minatti:

 Hello!

 I'm trying to add the same behaviour to multiple Tables, which are related 
 to each other. Thus i created a class SpecialBehaviour, which is included 
 in both Tables in their initialize() method:
 $this-addBehavior('SpecialBehaviour');

 It works fine, when only one of the tables is queried, but when executing 
 a Query that joins the two tables together, an error is thrown:
 *Cannot redeclare class Cake\Model\Behavior\SpecialBehavior*

 Is there another way to add a global behavior to multiple tables?

 thanks in advance!


-- 
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: CakePHP 3.0.0-alpha2 released

2014-07-28 Thread Dr. Tarique Sani
 I'll probably start on it very soon as most of the 'big' work items I
 wanted to get done for 3.0 are now complete.


Awesome!



-- 
=
The Conference Schedule Creator : http://shdlr.com

PHP for E-Biz : http://sanisoft.com
=

-- 
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.