问题标签 [cakephp-2.4]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
68 浏览

php - 我应该把我的 CakePHP 应用程序的初始数据放在哪里?

我开始使用 CakePHP 的控制台迁移。

我想知道我应该将应用程序的初始数据放在哪里。例如,如果我要第一次在开发人员机器上运行它,我需要设置一些包含数据的表。

正如我在官方书中看到的,他们推荐“CakeSchema 回调”,但每次运行时,schema.php 中的方法“public function after()”都会被重写:

这看起来也不是一个干净的方法。

我应该把这种指令放在哪里?

我正在运行 CakePHP 2.4

谢谢!

0 投票
1 回答
252 浏览

php - 如何绕过 CakePHP 中 requestAction 的 ACL 查询?

通过 requestAction 方法在元素中显示最近的帖子很好,但是如果使用 ACL 会导致冗余查询。有没有办法禁用这些?

注意:我的 CakePHP 版本是 2.4.2

0 投票
1 回答
212 浏览

php - saveAll() 在 beforeSave 中创建时不保存关联数据

下面是关联、保存调用和要保存的数据。它为 生成UPDATE查询Event,但没有生成查询来保存关联的EventInstance

EventInstance数据在事件的 beforeSave() 中创建。

它说它保存得很好 - 没有验证错误..等等。无论如何,我在 EventInstance 模型上没有验证数组。我也检查了,我的表没有任何问题,因为字段不允许 null ......等等。- 我通过将所有内容设置为允许为空来进行测试。

我不知道 - 这应该很简单 - 我之前已经做过 500 次了,但是对于这个,我显然遗漏了一些东西。

0 投票
0 回答
96 浏览

cakephp - Cakephp 视图在开发过程中被缓存

我正在使用 CakePHP 2.4.1 开发一个应用程序,所以我想在开发过程中关闭所有视图缓存。

我在 config/core.php 中更改了以下项目:

尽管进行了设置,但我的布局、元素和页面似乎仍被缓存了 30 秒左右。Css 文件更改不会被缓存。

如何防止在我的视图中缓存?

0 投票
1 回答
273 浏览

cakephp - CakePHP - 这些文件是不必要的吗?

当您下载 CakePHP 时,这些文件存在:

.editorconfig、.travis.yml、build.properties 和 build.xml

我以前从未真正需要编辑这些文件或将它们用于我的应用程序,但我从未删除它们。这些文件重要吗?或者我可以删除它们吗?

我正在使用 CakePHP 2.4.2 版

0 投票
2 回答
120 浏览

cakephp - CakePHP 应用程序的本地化问题

我正在开发一个 CakePHP 2 应用程序。

我的问题是我不知道用户点击链接后如何执行指令。

我的意图是在 Session 中写入一个值。用户单击一个标志图标,因此他指定了他的会话的语言。

然后我会跑

我该如何解决这个问题?谢谢

0 投票
1 回答
1747 浏览

cakephp - cakephp:自定义身份验证对象身份验证未调用

自定义身份验证对象中的身份验证方法永远不会被调用。这是一个错误还是我错过了什么?

我没有在日志中得到任何东西,我只是被重定向到用户/登录名(或我指定的那个)

蛋糕版本:2.4.1

如果我添加方法 getUser() (或 unauthenticated() ),那些会被调用,所以至少我知道 cake 找到了类等等。它只是跳过验证方法。

AppController 看起来像这样

我在这里发现了一个类似的问题:CakePHP 2.x custom "Authentication adapter "LdapAuthorize" is not found but there's the issue is typos.

0 投票
1 回答
2225 浏览

cakephp - CakePhp2.4: Auth->login() always returns false

Though my app has substantially more models and actions than the Simple ACL Controlled Application on the Cake main site, I've followed it to the letter but for one or two slight additions. All the same, I can't authorize any login actions and I don't understand why. Any help here would be hugely helpful, I've been pouring over the API, similar stackOverflow questions, etc. and am properly stuck. Below is the pertinent code from

  1. AppController
  2. Users Controllers
  3. User Model
  4. Users.login View
  5. Groups Controller
  6. Group Model

Update - Solved

If this helps, following from this answer on stackOverflow, I gave this a whirl: pr(AuthComponent::password($this->data[$this->alias]['password'])); before calling $this->Auth->login() and, sure enough, the password hash doesn't match (at all) the one in my database. Upon closer inspection, my password field was restricted to 32 characters when in fact it needed 36. Real facepalm moment.

1. AppController

2. Users Controller

3. User Model

4. User.login View

5. Groups Controller

6. Group Model

0 投票
0 回答
47 浏览

facebook - facebook 中的 CakePHP 表单在初始加载时验证

我在 CakePHP(2.4 版)中有一个简单的表单。如果我在浏览器中打开 url 一切正常,表单只有在我第一次单击提交后才会生效。但是,如果我将相同的表单放入 Facebook 应用程序(作为 Page Tab),相同的表单会立即验证并在用户单击提交之前输出所有错误(当然,因为所有必填字段在初始加载时都是空的)。

我的表单添加控制器:

任何帮助都会非常感谢,所以请提前!

0 投票
2 回答
219 浏览

php - cakephp 避免多次回调

假设我有一个User模型hasMany ItemsItem belongsTo User当然还有 )

每次Item在我的应用程序中的任何地方修改我都希望将电子邮件发送给他的用户(或他们的用户)

所以在我的项目模型中,我写了类似的东西

但是,当我在我的操作中同时编辑多个项目(即在 foreach 循环中)时,会发送几封电子邮件,但我只想要一封电子邮件,或者为参与更新的每个用户发送一封电子邮件。

我怎样才能做到这一点?

也许使用 cakephp 事件系统?