When I visit domain.ext/manage
Im getting the error:
Fatal error class 'View' not found
My code:
class ManageController extends ControllerBase
{
public function indexAction()
{
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
}
}
This is what is causing the problem
View::LEVEL_ACTION_VIEW
You're making reference to a constant from Phalcon\Mvc\View.
Add an "use" to this class in your code.
use Phalcon\Mvc\View;
class ManageController extends ControllerBase
{
public function indexAction()
{
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
}
}
Related
I am setting session variable in function of a controller like below.
use Illuminate\Support\Facades\Session;
class UserController extends Controller
{
public function store(Request $request)
{
session(['user_name' => $user_name]);
}
}
I am trying to access that session variable in another function of another controller.
use Illuminate\Support\Facades\Session;
class DashboardController extends Controller
{
public function __construct()
{
dd(session('user_name')); // I am not getting value here
}
}
I am not getting value from Session Variable.
You can do it like this
use Illuminate\Support\Facades\Session;
class UserController extends Controller
{
public function store(Request $request)
{
session()->put('user_name', $user_name);
}
}
And you can get it another controller or anywhere like this
session()->get('user_name');
Hope this will help you, thanks..
I've got sample third party Java code:
public class ApiClass extends PackagePrivateClass {
}
abstract class PackagePrivateClass {
public static class StaticClass {
}
}
So only ApiClass and StaticClass are public. In Java I can get reference to StaticClass with: ApiClass.StaticClass. For the same code in Kotlin I got Unresolved reference: StaticClass. I can't also get reference via PackagePrivateClass, because it's package private (captain obvious). Is there any hack to get reference to StaticClass (it's third party code so I can't simply make PackagePrivateClass public)?
I understand that it's probably 'by design', however it forbids me from using 3p code
It seems the only solution is to build Java wrapper class that your kotlin class can access to.
public class ApiClass extends PackagePrivateClass {
}
abstract class PackagePrivateClass {
public static class StaticClass {
void instanceFunction() {
}
static void classFunction() {
}
}
}
The adapter java class (StaticClassAdapter.java):
class StaticClassAdapter {
private static ApiClass.StaticClass staticClass;
void instanceFunction() {
staticClass.instanceFunction();
}
static void classFunction() {
PackagePrivateClass.StaticClass.classFunction();
}
}
So in your kotlin code...
class KotlinClass {
fun main() {
StaticClassAdapter().instanceFunction()
StaticClassAdapter.classFunction()
}
}
Please see the code below:
public partial class MyContentPage : ContentPage
{
public CreditCardView()
{
InitializeComponent();
}
}
It works as expected. Now say I want to inject a dependancy:
public partial class MyContentPage : ContentPage
{
private readonly IMyService _myService;
public CreditCardView(IMyService myService)
{
InitializeComponent();
_myService=myService;
}
}
With the second excerpt of code I see a compilation error: "The given key was not present in the dictionary". What is the problem? I have registered the dependancy.
I would like get key from sessions, but the compiler is complaining that the class is static when it is not. Can anyone please help me out?
using Microsoft.AspNetCore.Mvc;
using LitOnline_V1.Models;
using Microsoft.AspNetCore.Http;
namespace Test{
public class GetValidateUer{
public int GetUserValidation(){
var isValidated = HttpContext.Session.GetInt32("isValidated");
return isValidated;
}
}
}
Severity Code Description Project File Line Suppression State
Error CS0120 An object reference is required for the non-static field, method, or property 'HttpContext.Session'
hope it help
public class HomeController : Controller
{
public IActionResult Index()
{
MyMethod(HttpContext);
// Some Code
}
}
public void MyMethod(Microsoft.AspNetCore.Http.HttpContext context)
{
var host = $"{context.Request.Scheme}://{context.Request.Host}";
// Some Code
}
the error is :
The type AdListener cannot be a superinterface of FlyingPanda; a superinterface must be an interface
public class FlyingPanda extends Activity implements AdListener {
where is the problem i try to replace the implements kyeword by extends but the error still there.
need you help plz
According to the docs,
You can no longer implement AdListener from your Activity or class
You can use it as an anonymous inner class:
For Interstitial ads:
interstitalAd.setAdListener(new AdListener() {
public void onAdLoaded() {}
public void onAdFailedToLoad(int errorcode) {}
// Only implement methods you need.
});
And for banner ads
adView.setAdListener(new AdListener() {
public void onAdLoaded() {}
public void onAdFailedToLoad(int errorcode) {}
// Only implement methods you need.
});