Generating CRUD Code through Yii giving error - yii

i have completely done all the task that is Model generator Crud generator after that when there come try the link i click that link it gives the following error
YiiBase::include(Controller.php) [<a href='function.YiiBase-include'>function.YiiBase-include</a>]: failed to open stream: No such file or directory
i check my model and views folder and it successfully created all the required php pages.
can anyone tell me why this error is comming...

You need to have a custom Controller class placed in the /protected/controller folder. Extend that class from CController.
class Controller extends CController {
}
you will use later as a base class for your own controller classes.

This is actually due to a documented typo (Controller is missing the extra 'C') in the version of Gii that you are using.
All you have to do is update the controller file it generated from this:
class MyNewController extends Controller
{
to this:
class MyNewController extends CController
{

Related

In ASP.Net 6, Controller class is raising an error when inherited from class Controller

As you could see, in the image. I am not able to use the controller class as a base class to my HomeController.
Is there any update or should I change it to some other base controller?
Your namespace ends with .Controller. This confuses the compiler to understand what class it wants to use. Rename your namespace and try again.
Change your folder name from Controller to Controllers,and then change namespace from
EmployeeManagement.Controller to EmployeeManagement.Controllers.The name of your folder is conflicted with Microsoft.AspNetCore.Mvc.Controller.

How to create object from Data class? Kotlin

I have a
data class A(){
fun c(){}
} .
I need to create a fake implementation of it for testing, but it says that class must be open. open modifier is incompatible with data class. Any ways to do it?
To mock final classes update mockito
testCompile 'org.mockito:mockito-core:2.8.9'
and then add a folder in your resources folder called mockito-extensions that includes a text file called org.mockito.plugins.MockMaker. Inside there just add
mock-maker-inline
That should solve your problem

Silverstripe - Custom changes to a module

Not sure where to look for this. I want to make changes to a Silverstripe module I added to my site with composer but I don't want the custom code to be overwritten when I update the module at a later stage.
How can I make a few changes to some of the code without editing the core files? The code in question is in a function that is in a controller.
It definitely depends on your case.
If you want to add some custom methods use an Extension(see Simon's
answer)
If you want to add some database fields or relations, a DataExtension
is your friend
If the module is extensible and provides hooks, you
can change behaviour in your (you guessed it) Extension. Look for
$this->extend('functionName') in the module, you can modify stuff
in a method functionName() in your Extension
But sometimes it's a
bug or the module doesn't provide a hook you can use, then you have
to subclass the class and tell SilverStripe to use your Subclass instead:
class MySubClass extends SomeClass
{
public function doSomething()
$something = parent::doSomething();
//your changes
return $something;
}
}
You just need your changes and overwritten methods in your subclass, no need to copy all stuff in your subclass. This way you'll get most module updates later on.
Then you need to configure Injector to use your MySubClass instead of SomeClass in your config.yml:
Injector:
SomeClass:
class: MySubClass
You can make your own extension to it, e.g. class MyModuleExtension extends Extension
And override/edit/change code in there.
In your config.yml, register the new extension like so:
OriginalController:
extensions:
- MyModuleExtension

Geb/Groovy : Page object class considered as a property in another when refering to with "to" option

I am new to Groovy programing and I am currently trying to test a web app with Geb and Spock on IntelliJ IDE. I wanted to try a simple script first without using Spock, that is why I use a simple main class for creating Browser and so on and run some basic tests (understand: verifying if I am at the correct page).
Everything was working well but I had a lot of page class that were melt in the same folder as my main class, modules and so on. So I decided to clean up by using packages. Here is my project folders:
src
---main
------groovy
------------app
---------------module
---------------pages
---------------templates
module folder contains the modules used in my pages
pages folder contains the actual page the browser will browse
templates folder contains some super pages class for not repeating content through pages instances.
My class Main with main method is in app folder.
So I re-run the code that was previously working well (when every source files were in the same folder) and I get an error Exception in thread "main" groovy.lang.MissingPropertyException: No such property: homePage for class: app.pages.loginPage
The line that seems to be the problem is this one (in loginPage.groovy) :
loginButton(to: homePage){$("input", id: "loginButton_submit")}
Which is in the static content of loginPage class.
I don't understand why I get this error as loginPage and homePage are in the same package. I guess I don't understand some groovy stuff here or compiling mechanics.
Here is the error messages I got :
The package is the correct one both in homePage and loginPage (they are in the same one) so the class seems to be resolved. But when running, `homePage` is considered as a static property of `loginPage`I suppose and as it is not declared in `loginPage` properties it cannot work. Here is my log :
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: homePage for class: app.pages.loginPage
at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:1004)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1859)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1835)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3735)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:175)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:306)
at groovy.lang.Closure.getProperty(Closure.java:295)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:50)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at app.pages.loginPage$__clinit__closure4.doCall(loginPage.groovy:28)...
Do you have any ideas ?
Check to see if the package your homePage belongs to was updated when you moved it from "main" to "pages":
package app.pages
class homePage extends Page {
}
If the package is incorrect or undeclared on the homePage class your loginPage will not be able to resolve it
Finally solved it thanks to this comment:
Note that by convention class names in Java and Groovy usually start with a capital letter.
All my classes where considered as variable. I still don't get why the behavior is different in default package so if anyone has a clue...
Thanks all for your help.

Why Can't I Inherit IO.Directory?

Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable!
I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function.
Please advise and I will send you a six pack. OK nevermind I'm not sending you anything but if you come to the bar tonight I will hook you up and then beat you in pool.
From the Meta Data of .NET
namespace System.IO
{
// Summary:
// Exposes static methods for creating, moving, and enumerating through directories
// and subdirectories. This class cannot be inherited.
[ComVisible(true)]
public static class Directory
You cannot inherit from a Static Class.
Are you using C# 3.0 VB.NET 2008 -- then you could add an Extension Method
If you use the DirectoryInfo class, you will have access to a MoveTo function.
EDIT: I'll correct myself... The static Directory class already has a Move method.
I'd guess that Reflector isn't picking up the sealed attribute correctly for VB (or perhaps just not displaying it properly). If you look at the IL, it is sealed:
class public abstract auto ansi sealed beforefieldinit Directory