Konrad
Kluźniak
Webdeveloper /
Designer
Temat: cake3
Cześć,Chciałem zapytać, czy macie jakieś dziwne przeczucie, że ten nowy cake trochę się "zamotał"?
czytam dokumentację, i już w samym ORM jest trochę przekombinowane, w cake2 wszytko było na tacy i jak trzeba.
W Trójce nazewnictwo już kombinowane ( jak model nie ma asocjacji, dajemy w singular, jak ma - plural ), oczywiście to już nie jest stary dobry model, tylko obiekt, tu znów - albo tabela albo rekord - entity.
Jestem zmartwiony już samym wstępem:
To get started you don’t have to write any code
use Cake\ORM\TableRegistry;
$articles = TableRegistry::get('Articles');
$query = $articles->find();
foreach ($query as $row) {
echo $row->title;
}
Czy to kod dla kontrolera, który może sobie załądowac dane, jak na przykład $this->loadModel() ?
If we wanted to customize our ArticlesTable class adding some associations or defining some additional methods we would add the following to src/Model/Table/ArticlesTable.php after the <?php opening tag:
namespace App\Model\Table;
use Cake\ORM\Table;
class ArticlesTable extends Table {
}
To pewnie kod do stworzenia obiektu tabeli ( coś jak stary dobry Model )
A poniżej mieszanka:
Table classes use the CamelCased version of the table name with the Table suffix as the class name. Once your class has been created you get a reference to it using the ORM\TableRegistry as before:
use Cake\ORM\TableRegistry;
// Now $articles is an instance of our ArticlesTable class.
$articles = TableRegistry::get('Articles');
Co jest grane ? Gdzie, gdzie to użyć ?
Dalej:
Entities use the singular CamelCase version of the table name as their class name by default.
Uwaga:
If you need to customize which entity a table uses you can use the entityClass() method to set a specific classname.
CO ? Mam metody do szukania co jest czyje, gdzie i kiedy ? Przecież w 2.0 jeden model robił swoje.
Cake dev team chwali się nową validacją, bo twierdzą że stara była zamotana, aż się boję nowej :)
Pozdrawiam.
PS: Czy podoba Wam się nowy Cake ?Ten post został edytowany przez Autora dnia 27.12.14 o godzinie 23:54