diff --git a/.phpstorm.meta.php/.ide-helper.meta.php b/.phpstorm.meta.php/.ide-helper.meta.php index 82e7bcbd..ae553ed6 100644 --- a/.phpstorm.meta.php/.ide-helper.meta.php +++ b/.phpstorm.meta.php/.ide-helper.meta.php @@ -216,12 +216,14 @@ 'Calendar', 'Captcha', 'CheckHttpCache', + 'Comment', 'Common', 'CountryStateHelper', - 'Favorite', + 'Favoriteable', 'Flash', 'FormProtection', 'LegacyAuth', + 'Likeable', 'Mobile', 'Plugins', 'Preparer', @@ -229,6 +231,7 @@ 'RefererRedirect', 'Search', 'Setup', + 'Starable', 'Superimpose', 'TestFixtures', 'TestGenerator', @@ -246,9 +249,12 @@ 'Captcha.Captcha' => \Captcha\Controller\Component\CaptchaComponent::class, 'Captcha.Preparer' => \Captcha\Controller\Component\PreparerComponent::class, 'CheckHttpCache' => \Cake\Controller\Component\CheckHttpCacheComponent::class, + 'Comments.Comment' => \Comments\Controller\Component\CommentComponent::class, 'Data.CountryStateHelper' => \Data\Controller\Component\CountryStateHelperComponent::class, 'Expose.Superimpose' => \Expose\Controller\Component\SuperimposeComponent::class, - 'Favorites.Favorite' => \Favorites\Controller\Component\FavoriteComponent::class, + 'Favorites.Favoriteable' => \Favorites\Controller\Component\FavoriteableComponent::class, + 'Favorites.Likeable' => \Favorites\Controller\Component\LikeableComponent::class, + 'Favorites.Starable' => \Favorites\Controller\Component\StarableComponent::class, 'Flash' => \Cake\Controller\Component\FlashComponent::class, 'FormProtection' => \Cake\Controller\Component\FormProtectionComponent::class, 'Ratings.Rating' => \Ratings\Controller\Component\RatingComponent::class, @@ -328,6 +334,7 @@ 'CakePdf' => \Cake\Http\BaseApplication::class, 'Calendar' => \Cake\Http\BaseApplication::class, 'Captcha' => \Cake\Http\BaseApplication::class, + 'Comments' => \Cake\Http\BaseApplication::class, 'CsvView' => \Cake\Http\BaseApplication::class, 'Data' => \Cake\Http\BaseApplication::class, 'DatabaseLog' => \Cake\Http\BaseApplication::class, @@ -432,6 +439,7 @@ \Cake\Datasource\ModelAwareTrait::fetchModel(0), map([ 'Captcha.Captchas' => \Captcha\Model\Table\CaptchasTable::class, + 'Comments.Comments' => \Comments\Model\Table\CommentsTable::class, 'Data.Addresses' => \Data\Model\Table\AddressesTable::class, 'Data.Cities' => \Data\Model\Table\CitiesTable::class, 'Data.Continents' => \Data\Model\Table\ContinentsTable::class, @@ -610,6 +618,7 @@ \Cake\ORM\Locator\LocatorAwareTrait::fetchTable(0), map([ 'Captcha.Captchas' => \Captcha\Model\Table\CaptchasTable::class, + 'Comments.Comments' => \Comments\Model\Table\CommentsTable::class, 'Data.Addresses' => \Data\Model\Table\AddressesTable::class, 'Data.Cities' => \Data\Model\Table\CitiesTable::class, 'Data.Continents' => \Data\Model\Table\ContinentsTable::class, @@ -670,6 +679,7 @@ \Cake\ORM\Locator\LocatorInterface::get(0), map([ 'Captcha.Captchas' => \Captcha\Model\Table\CaptchasTable::class, + 'Comments.Comments' => \Comments\Model\Table\CommentsTable::class, 'Data.Addresses' => \Data\Model\Table\AddressesTable::class, 'Data.Cities' => \Data\Model\Table\CitiesTable::class, 'Data.Continents' => \Data\Model\Table\ContinentsTable::class, @@ -732,6 +742,7 @@ 'Calendar.Calendar', 'Captcha.Captcha', 'Captcha.PassiveCaptcha', + 'Comments.Commentable', 'CounterCache', 'DebugKit.Timed', 'Expose.Expose', @@ -765,6 +776,7 @@ \Cake\ORM\Table::belongToMany(0), map([ 'Captcha.Captchas' => \Cake\ORM\Association\BelongsToMany::class, + 'Comments.Comments' => \Cake\ORM\Association\BelongsToMany::class, 'Data.Addresses' => \Cake\ORM\Association\BelongsToMany::class, 'Data.Cities' => \Cake\ORM\Association\BelongsToMany::class, 'Data.Continents' => \Cake\ORM\Association\BelongsToMany::class, @@ -825,6 +837,7 @@ \Cake\ORM\Table::belongsTo(0), map([ 'Captcha.Captchas' => \Cake\ORM\Association\BelongsTo::class, + 'Comments.Comments' => \Cake\ORM\Association\BelongsTo::class, 'Data.Addresses' => \Cake\ORM\Association\BelongsTo::class, 'Data.Cities' => \Cake\ORM\Association\BelongsTo::class, 'Data.Continents' => \Cake\ORM\Association\BelongsTo::class, @@ -908,6 +921,7 @@ \Cake\ORM\Table::hasMany(0), map([ 'Captcha.Captchas' => \Cake\ORM\Association\HasMany::class, + 'Comments.Comments' => \Cake\ORM\Association\HasMany::class, 'Data.Addresses' => \Cake\ORM\Association\HasMany::class, 'Data.Cities' => \Cake\ORM\Association\HasMany::class, 'Data.Continents' => \Cake\ORM\Association\HasMany::class, @@ -968,6 +982,7 @@ \Cake\ORM\Table::hasOne(0), map([ 'Captcha.Captchas' => \Cake\ORM\Association\HasOne::class, + 'Comments.Comments' => \Cake\ORM\Association\HasOne::class, 'Data.Addresses' => \Cake\ORM\Association\HasOne::class, 'Data.Cities' => \Cake\ORM\Association\HasOne::class, 'Data.Continents' => \Cake\ORM\Association\HasOne::class, @@ -1031,6 +1046,7 @@ 'Bitmasked', 'Calendar', 'Captcha', + 'Commentable', 'Confirmable', 'CounterCache', 'Encryption', @@ -1168,6 +1184,9 @@ 'plugin.Captcha.Captchas', 'plugin.Captcha.Comments', 'plugin.Captcha.Sessions', + 'plugin.Comments.Comments', + 'plugin.Comments.Posts', + 'plugin.Comments.Users', 'plugin.Data.Addresses', 'plugin.Data.Cities', 'plugin.Data.Continents', @@ -1227,6 +1246,7 @@ 'plugin.Sandbox.SandboxAnimals', 'plugin.Sandbox.SandboxCategories', 'plugin.Sandbox.SandboxPosts', + 'plugin.Sandbox.SandboxProfiles', 'plugin.Sandbox.SandboxRatings', 'plugin.Sandbox.SandboxUsers', 'plugin.Search.Articles', @@ -1420,6 +1440,8 @@ 'ip', 'is_error', 'is_html', + 'is_private', + 'is_spam', 'iso2', 'iso3', 'job_group', @@ -1543,6 +1565,7 @@ 'CakeDto.Template' => \CakeDto\View\Helper\TemplateHelper::class, 'Calendar.Calendar' => \Calendar\View\Helper\CalendarHelper::class, 'Captcha.Captcha' => \Captcha\View\Helper\CaptchaHelper::class, + 'Comments.Comments' => \Comments\View\Helper\CommentsHelper::class, 'Data.Continent' => \Data\View\Helper\ContinentHelper::class, 'Data.Data' => \Data\View\Helper\DataHelper::class, 'Data.MimeType' => \Data\View\Helper\MimeTypeHelper::class, @@ -1641,10 +1664,12 @@ 'Queue.search', 'Queue.yes_no', 'Sandbox.actions', + 'Sandbox.comments/comments', 'Sandbox.feed/element', 'Sandbox.inflector/result-row', 'Sandbox.inflector/results', 'Sandbox.navigation/ajax', + 'Sandbox.navigation/comments', 'Sandbox.navigation/decimal', 'Sandbox.navigation/dto', 'Sandbox.navigation/favorite', @@ -1692,6 +1717,7 @@ 'CakeDto.Template' => \CakeDto\View\Helper\TemplateHelper::class, 'Calendar.Calendar' => \Calendar\View\Helper\CalendarHelper::class, 'Captcha.Captcha' => \Captcha\View\Helper\CaptchaHelper::class, + 'Comments.Comments' => \Comments\View\Helper\CommentsHelper::class, 'Data.Continent' => \Data\View\Helper\ContinentHelper::class, 'Data.Data' => \Data\View\Helper\DataHelper::class, 'Data.MimeType' => \Data\View\Helper\MimeTypeHelper::class, @@ -1774,6 +1800,7 @@ 'CakeDto.Template', 'Calendar.Calendar', 'Captcha.Captcha', + 'Comments.Comments', 'Data.Continent', 'Data.Data', 'Data.MimeType', @@ -1911,6 +1938,66 @@ argumentsSet('entityFields:Captcha\Model\Entity\Captcha'), ); + expectedArguments( + \Comments\Model\Entity\Comment::get(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::getError(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::getInvalidField(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::getOriginal(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::has(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::hasValue(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::isDirty(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::isEmpty(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::setDirty(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + + expectedArguments( + \Comments\Model\Entity\Comment::setError(), + 0, + argumentsSet('entityFields:Comments\Model\Entity\Comment'), + ); + expectedArguments( \Data\Model\Entity\Continent::get(), 0, @@ -4275,6 +4362,7 @@ 'cake_dto', 'calendar', 'captcha', + 'comments', 'data', 'database_log', 'debug_kit', @@ -4877,6 +4965,8 @@ 'ip', 'is_error', 'is_html', + 'is_private', + 'is_spam', 'iso2', 'iso3', 'job_group', @@ -5031,10 +5121,13 @@ 'CakeDto.strictTypes', 'Captcha', 'Captcha.maxPerUser', + 'Comments', + 'Comments.allowAnonymous', 'Config', 'Config.adminEmail', 'DatabaseLog', 'DatabaseLog.datasource', + 'DatabaseLog.disableAutoTable', 'DatabaseLog.limit', 'DatabaseLog.maxLength', 'DatabaseLog.monitor', @@ -5051,8 +5144,12 @@ 'Error.skipLog', 'Error.trace', 'Favorites', - 'Favorites.controllerModels', - 'Favorites.controllerModels.Posts', + 'Favorites.icons', + 'Favorites.models', + 'Favorites.models.FavoritePosts', + 'Favorites.models.LikePosts', + 'Favorites.models.StarPosts', + 'Favorites.userModelClass', 'Feedback', 'Feedback.configuration', 'Feedback.configuration.Filesystem', @@ -5074,6 +5171,7 @@ 'Icon', 'Icon.checkExistence', 'Icon.map', + 'Icon.map.add', 'Icon.map.admin', 'Icon.map.chart-bar', 'Icon.map.contra', @@ -5165,6 +5263,7 @@ 'plugins.CakePdf', 'plugins.Calendar', 'plugins.Captcha', + 'plugins.Comments', 'plugins.CsvView', 'plugins.Data', 'plugins.DatabaseLog', @@ -5246,6 +5345,26 @@ 'used', ); + registerArgumentsSet( + 'entityFields:Comments\Model\Entity\Comment', + 'child_comments', + 'content', + 'created', + 'email', + 'foreign_key', + 'id', + 'is_private', + 'is_spam', + 'model', + 'modified', + 'name', + 'parent_comment', + 'parent_id', + 'title', + 'user', + 'user_id', + ); + registerArgumentsSet( 'entityFields:Data\Model\Entity\Continent', 'child_continents', @@ -5716,6 +5835,7 @@ registerArgumentsSet( 'icons', '500px', + 'add', 'address-book', 'address-book-o', 'address-card', @@ -13079,6 +13199,12 @@ 'CakeDto.Admin/Generate::index', 'CakeDto.Admin/Generate::schema', 'Captcha.Captcha::display', + 'Comments.Admin/Comments::delete', + 'Comments.Admin/Comments::edit', + 'Comments.Admin/Comments::index', + 'Comments.Admin/Comments::view', + 'Comments.Comments::add', + 'Comments.Comments::delete', 'Contact::index', 'Data.Admin/Addresses::add', 'Data.Admin/Addresses::delete', @@ -13298,6 +13424,8 @@ 'Sandbox.Captchas::math', 'Sandbox.Captchas::modelLess', 'Sandbox.ChronosExamples::index', + 'Sandbox.CommentExamples::basic', + 'Sandbox.CommentExamples::index', 'Sandbox.Conventions::index', 'Sandbox.Csv::index', 'Sandbox.Csv::pagination', @@ -13518,6 +13646,7 @@ 'tableNames', 'bitmasked_records', 'captchas', + 'comments_comments', 'continents', 'countries', 'currencies', diff --git a/composer.lock b/composer.lock index eacb08e3..f6afa0df 100644 --- a/composer.lock +++ b/composer.lock @@ -225,16 +225,16 @@ }, { "name": "cakephp/cakephp", - "version": "5.0.6", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/cakephp/cakephp.git", - "reference": "3f26c5bbbae99164852ba9607d11ff1b36fda1c9" + "reference": "97f49cfd96358132c33e659d0367549e864d6dad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/cakephp/zipball/3f26c5bbbae99164852ba9607d11ff1b36fda1c9", - "reference": "3f26c5bbbae99164852ba9607d11ff1b36fda1c9", + "url": "https://api.github.com/repos/cakephp/cakephp/zipball/97f49cfd96358132c33e659d0367549e864d6dad", + "reference": "97f49cfd96358132c33e659d0367549e864d6dad", "shasum": "" }, "require": { @@ -342,7 +342,7 @@ "issues": "https://github.com/cakephp/cakephp/issues", "source": "https://github.com/cakephp/cakephp" }, - "time": "2024-03-09T03:36:26+00:00" + "time": "2024-04-06T02:35:20+00:00" }, { "name": "cakephp/chronos", @@ -1541,23 +1541,23 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/cakephp-comments.git", - "reference": "9f560255ae432bc30ecd95f384001bb9818cb125" + "reference": "d3e498aab4b6cbe84d8135be63a86bdd3111e9c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/cakephp-comments/zipball/9f560255ae432bc30ecd95f384001bb9818cb125", - "reference": "9f560255ae432bc30ecd95f384001bb9818cb125", + "url": "https://api.github.com/repos/dereuromark/cakephp-comments/zipball/d3e498aab4b6cbe84d8135be63a86bdd3111e9c4", + "reference": "d3e498aab4b6cbe84d8135be63a86bdd3111e9c4", "shasum": "" }, "require": { "cakephp/cakephp": "^5.0.0", - "php": ">=8.2" + "php": ">=8.1" }, "require-dev": { - "cakephp/migrations": "^4.0.1", + "cakephp/migrations": "^4.1.1", "dereuromark/cakephp-tinyauth": "^4.1.0", "fig-r/psr2r-sniffer": "dev-master", - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^10.2" }, "default-branch": true, "type": "cakephp-plugin", @@ -1594,7 +1594,7 @@ "issues": "https://github.com/dereuromark/cakephp-comments/issues", "source": "https://github.com/dereuromark/cakephp-comments/" }, - "time": "2024-04-02T17:50:52+00:00" + "time": "2024-04-08T02:02:26+00:00" }, { "name": "dereuromark/cakephp-data", @@ -1664,12 +1664,12 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/CakePHP-DatabaseLog.git", - "reference": "4d0fb7462bf7192e5b596a1bafc0a18925186894" + "reference": "e1c920572b0c6db5e37099d21089d54008b296de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/CakePHP-DatabaseLog/zipball/4d0fb7462bf7192e5b596a1bafc0a18925186894", - "reference": "4d0fb7462bf7192e5b596a1bafc0a18925186894", + "url": "https://api.github.com/repos/dereuromark/CakePHP-DatabaseLog/zipball/e1c920572b0c6db5e37099d21089d54008b296de", + "reference": "e1c920572b0c6db5e37099d21089d54008b296de", "shasum": "" }, "require": { @@ -1727,7 +1727,7 @@ "issues": "https://github.com/dereuromark/CakePHP-DatabaseLog/issues", "source": "https://github.com/dereuromark/CakePHP-DatabaseLog/" }, - "time": "2024-03-31T21:47:33+00:00" + "time": "2024-04-07T02:05:05+00:00" }, { "name": "dereuromark/cakephp-decimal", @@ -2313,12 +2313,12 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/cakephp-queue.git", - "reference": "6ae2b1748d9888590f953b11f1be51b9d2b04cf6" + "reference": "3455726d9b31aef1951e7112bc61c6aac00fb38f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/cakephp-queue/zipball/6ae2b1748d9888590f953b11f1be51b9d2b04cf6", - "reference": "6ae2b1748d9888590f953b11f1be51b9d2b04cf6", + "url": "https://api.github.com/repos/dereuromark/cakephp-queue/zipball/3455726d9b31aef1951e7112bc61c6aac00fb38f", + "reference": "3455726d9b31aef1951e7112bc61c6aac00fb38f", "shasum": "" }, "require": { @@ -2379,7 +2379,7 @@ "issues": "https://github.com/dereuromark/cakephp-queue/issues", "source": "https://github.com/dereuromark/cakephp-queue" }, - "time": "2024-04-04T15:31:25+00:00" + "time": "2024-04-06T17:45:14+00:00" }, { "name": "dereuromark/cakephp-ratings", @@ -2387,12 +2387,12 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/cakephp-ratings.git", - "reference": "d7e95c9bdb22f23710cdd4ec50262a3b3cd3d0f0" + "reference": "c7db3e9150edf84aba637451bed5b462e84130ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/cakephp-ratings/zipball/d7e95c9bdb22f23710cdd4ec50262a3b3cd3d0f0", - "reference": "d7e95c9bdb22f23710cdd4ec50262a3b3cd3d0f0", + "url": "https://api.github.com/repos/dereuromark/cakephp-ratings/zipball/c7db3e9150edf84aba637451bed5b462e84130ec", + "reference": "c7db3e9150edf84aba637451bed5b462e84130ec", "shasum": "" }, "require": { @@ -2445,7 +2445,7 @@ "source": "https://github.com/dereuromark/cakephp-ratings", "wiki": "https://github.com/dereuromark/cakephp-ratings/blob/master/docs" }, - "time": "2024-03-31T21:49:27+00:00" + "time": "2024-04-07T18:05:01+00:00" }, { "name": "dereuromark/cakephp-setup", @@ -2515,16 +2515,16 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/cakephp-shim.git", - "reference": "ab77bfc5e220c58e4d3d112b3e63d734f62445ee" + "reference": "89dadfd680d9123f8a53afc403356568737561f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/cakephp-shim/zipball/ab77bfc5e220c58e4d3d112b3e63d734f62445ee", - "reference": "ab77bfc5e220c58e4d3d112b3e63d734f62445ee", + "url": "https://api.github.com/repos/dereuromark/cakephp-shim/zipball/89dadfd680d9123f8a53afc403356568737561f1", + "reference": "89dadfd680d9123f8a53afc403356568737561f1", "shasum": "" }, "require": { - "cakephp/cakephp": "^5.0.0", + "cakephp/cakephp": "^5.0.7", "php": ">=8.1" }, "require-dev": { @@ -2563,7 +2563,7 @@ "issues": "https://github.com/dereuromark/cakephp-shim/issues", "source": "https://github.com/dereuromark/cakephp-shim" }, - "time": "2024-03-31T21:57:01+00:00" + "time": "2024-04-06T17:37:07+00:00" }, { "name": "dereuromark/cakephp-tags", @@ -8212,12 +8212,12 @@ "source": { "type": "git", "url": "https://github.com/dereuromark/cakephp-ide-helper.git", - "reference": "a5d91561944e222f914473ea6dda42058286f8ea" + "reference": "3098a76864cbf3a3ac97155e9b5292d6290d90d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dereuromark/cakephp-ide-helper/zipball/a5d91561944e222f914473ea6dda42058286f8ea", - "reference": "a5d91561944e222f914473ea6dda42058286f8ea", + "url": "https://api.github.com/repos/dereuromark/cakephp-ide-helper/zipball/3098a76864cbf3a3ac97155e9b5292d6290d90d4", + "reference": "3098a76864cbf3a3ac97155e9b5292d6290d90d4", "shasum": "" }, "require": { @@ -8281,7 +8281,7 @@ "type": "github" } ], - "time": "2024-03-31T22:01:29+00:00" + "time": "2024-04-07T18:01:16+00:00" }, { "name": "dereuromark/cakephp-ide-helper-extra", diff --git a/config/app_custom.php b/config/app_custom.php index f60843f7..cfaa87f8 100644 --- a/config/app_custom.php +++ b/config/app_custom.php @@ -209,6 +209,7 @@ ], ], 'map' => [ + 'add' => 'fa4:plus', 'view' => 'fa4:eye', 'delete' => 'fa4:times', 'yes' => 'fa4:check', @@ -326,6 +327,10 @@ 'userModelClass' => 'Sandbox.SandboxUsers', 'icons' => \Favorites\View\Helper\FavoritesHelper::ICONS_GITHUB, ], + + 'Comments' => [ + 'allowAnonymous' => true, + ], ]; if (str_contains((string)getenv('DB_URL'), 'mysql')) { diff --git a/config/auth_allow.ini b/config/auth_allow.ini index d0480f38..96e7acde 100644 --- a/config/auth_allow.ini +++ b/config/auth_allow.ini @@ -25,6 +25,7 @@ Sandbox.Csv = * Sandbox.DecimalExamples = * Sandbox.Examples = * Sandbox.ExposeExamples = * +Sandbox.CommentExamples = * Sandbox.FavoriteExamples = * Sandbox.FeedExamples = * Sandbox.FeedbackExamples = * diff --git a/plugins/Sandbox/src/Controller/CommentExamplesController.php b/plugins/Sandbox/src/Controller/CommentExamplesController.php new file mode 100644 index 00000000..58960b1e --- /dev/null +++ b/plugins/Sandbox/src/Controller/CommentExamplesController.php @@ -0,0 +1,83 @@ +fetchTable('Sandbox.SandboxPosts')->ensureDemoData(); + + // Creating demo data + $user = $this->user(); + // For demo purposes we use Configure instead of session + Configure::write('Auth.User.id', $user->id); + + // You usually only need one of them per entity type + $this->loadComponent('Comments.Comment', ['actions' => ['basic']]); + } + + /** + * + * @param \Cake\Event\EventInterface $event + * + * @return void + */ + public function beforeFilter(EventInterface $event) { + parent::beforeFilter($event); + } + + /** + * @return void + */ + public function index() { + $user = $this->user(); + + $this->set(compact('user')); + } + + /** + * @return \Cake\Http\Response|null|void + */ + public function basic() { + $user = $this->user(); + $sandboxPost = $this->fetchTable('Sandbox.SandboxPosts')->find() + ->firstOrFail(); + + $this->set(compact('user', 'sandboxPost')); + } + + /** + * @return \Sandbox\Model\Entity\SandboxUser + */ + protected function user(): SandboxUser { + // For the demo we bind it to the user session to avoid other people testing it to have side-effects :) + $sid = $this->request->getSession()->id() ?: env('REMOTE_ADDR'); + $user = $this->fetchTable('Sandbox.SandboxUsers')->find() + ->where(['email' => $sid . '@example.de']) + ->first(); + if (!$user) { + $user = $this->fetchTable('Sandbox.SandboxUsers')->newEntity([ + 'username' => 'DemoUser', + 'slug' => 'demo-user', + 'email' => $sid . '@example.de', + 'password' => '', + ]); + $this->fetchTable('Sandbox.SandboxUsers')->saveOrFail($user); + } + + return $user; + } + +} diff --git a/plugins/Sandbox/src/Model/Table/SandboxPostsTable.php b/plugins/Sandbox/src/Model/Table/SandboxPostsTable.php index dbd4240a..5ca2ddbe 100644 --- a/plugins/Sandbox/src/Model/Table/SandboxPostsTable.php +++ b/plugins/Sandbox/src/Model/Table/SandboxPostsTable.php @@ -31,7 +31,7 @@ class SandboxPostsTable extends Table { /** * @var array */ - public $actsAs = [ + public array $actsAs = [ 'Tools.Slugged', 'Search.Search', 'Tags.Tag' => ['taggedCounter' => false], diff --git a/plugins/Sandbox/templates/CommentExamples/basic.php b/plugins/Sandbox/templates/CommentExamples/basic.php new file mode 100644 index 00000000..b9584418 --- /dev/null +++ b/plugins/Sandbox/templates/CommentExamples/basic.php @@ -0,0 +1,39 @@ + + + +
+ +

Demo as Guest

+ +

title); ?>

+

+ content); ?> +

+ +
Comments
+ + comments) { ?> + comments as $comment) { + ?> +

content) ?>

+ + + + element('comments/comments', ['alias' => 'SandboxPosts', 'id' => $sandboxPost->id]); + ?> + +
diff --git a/plugins/Sandbox/templates/CommentExamples/index.php b/plugins/Sandbox/templates/CommentExamples/index.php new file mode 100644 index 00000000..5568febe --- /dev/null +++ b/plugins/Sandbox/templates/CommentExamples/index.php @@ -0,0 +1,33 @@ + + + +
+ +

Basic Usage

+

The most common use cases are usually

+ + +

Give it a try

+

+ Hello username); ?>, +
the following examples will be using this account to "comment" things. +

+ +

Note: +
+ The following examples are not using AJAX for simplicity. With AJAX the experience is way better, though. +

+ + +
diff --git a/plugins/Sandbox/templates/FavoriteExamples/index.php b/plugins/Sandbox/templates/FavoriteExamples/index.php index f802e7b5..be94bde1 100644 --- a/plugins/Sandbox/templates/FavoriteExamples/index.php +++ b/plugins/Sandbox/templates/FavoriteExamples/index.php @@ -4,7 +4,6 @@ * @var \Sandbox\Model\Entity\SandboxUser $user */ -$this->loadHelper('Queue.QueueProgress'); ?>