掲示板

Persistence and Service variables in a Hook?

thumbnail
12年前 に Cameron McBride によって更新されました。

Persistence and Service variables in a Hook?

Expert 投稿: 269 参加年月日: 11/02/08 最新の投稿
I have a Calendar customization that works great as an ext plugin but I was trying to get this guy working as a hook.

In there are variables like:
portletPreferencesLocalService
companyPersistence.findByPrimaryKey
mailService
userPersistence
calEventPersistence

Is there some magical way to use these variables that are available in CalEvenLocalSeriveImpl in my hook version that extends it (CalEventLocalServiceWrapper)?

I found a post needing the exact same thing but it was older and with not answer: http://www.liferay.com/community/forums/-/message_boards/view_message/4438016#_19_message_4438016
thumbnail
12年前 に Sandeep Nair によって更新されました。

RE: Persistence and Service variables in a Hook?

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Hi,

Is it possible for you to use the corresponding LocalServiceUtil class instead of localservice. for example

portletPreferencesLocalService = PortletPreferencesLocalServiceUtil

companyPersistence.findByPrimaryKey = CompanyLocalServiceUtil.getCompany(companyId)

mailService = MailServiceUtil

userPersistence = UserLocalServiceUtil.getUser(userId)

calEventPersistence = CalEventLocalServiceUti


Regards,
Sandeep
thumbnail
12年前 に Cameron McBride によって更新されました。

RE: Persistence and Service variables in a Hook?

Expert 投稿: 269 参加年月日: 11/02/08 最新の投稿
Well that has just about done the trick, thanks! PortletPreferencesLocalServiceUtil, CompanyLocalServiceUtil, UserLocalServiceUtil and CalEventUtil took care of everything but one, ContentUtil.

return ContentUtil.get(PropsUtil.get(
    PropsKeys.CALENDAR_EMAIL_EVENT_REMINDER_BODY));

ContentUtil must be turning a template file into a pretty email, except it is not accessible. Once I get that sorted out I will have created a hook to send reminders to the whole group and can remove that from my ext plugin!

The only other irritating piece is since you can't add your own custom class into a hook I have to hardcode some things in the JSP that normally I would pull from a constant class like CalEventConstants.

Update 2:27pm:
I used PortalClassInvoker to access ContentUtil and now the whole thing is working. Take that ext plugin system!